package com.tjtt.gwm.action;

import java.util.Enumeration;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLEncoder;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import jxl.Cell;
import jxl.CellType;
import jxl.DateCell;
import jxl.Sheet;
import jxl.Workbook;

import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.struts2.ServletActionContext;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.hibernate.Session;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.opensymphony.xwork2.ActionContext;
import com.tjtt.common.utils.ExcelExportUtil;
import com.tjtt.gwm.bean.TdmEquipment;
import com.tjtt.gwm.bean.TdmEquipmentInfo;
import com.tjtt.gwm.bean.TdmEquipmentMain;
import com.tjtt.gwm.bean.TdmFaultRecord;
import com.tjtt.gwm.bean.TdmHetong;
import com.tjtt.gwm.bean.TdmMeasurementInfo;
import com.tjtt.gwm.bean.TdmPartsReplace;
import com.tjtt.gwm.bean.Yiqijhjl;
import com.tjtt.gwm.bean.Yiqisjjl;
import com.tjtt.gwm.bean.Yiqisxjl;
import com.tjtt.gwm.service.DbService;
import com.tjtt.gwm.service.EquipmentService;
import com.tjtt.tdm.base.BaseAction;
import com.tjtt.tdm.base.GenerateSequenceUtil;
import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.base.StringUtil;
import com.tjtt.tdm.exception.DaoException;
import com.tjtt.tdm.exception.ServiceException;
import com.tjtt.tdm.fileupload.bean.TdmAttachment;
import com.tjtt.tdm.fileupload.service.TdmAttachmentService;
import com.tjtt.tdm.form.bean.TdmAnnex;
import com.tjtt.tdm.form.service.IAutoService;
import com.tjtt.tdm.system.bean.LogInfo;
import com.tjtt.tdm.system.service.LogService;
import com.tjtt.tdm.util.ExcelTool;
import com.tjtt.tdm.util.PubMethod;

public class EquipmentAction extends BaseAction {
	private DbService dbService;
	private EquipmentService epService;
	private IAutoService autoService;
	private TdmEquipment equipment;
	private Long eid;
	private File filePath;
	private File filePDF;
	private File filePhoto;
	private List uploadfile;
	private List uploadfileFileName;
	// 导入Excel文件使用
	private boolean isHasChild; // 是否含有子表
	private String strFieldValue; // 字段值	
	private LogService logService;
	
	
	
	public LogService getLogService() {
		return logService;
	}

	public void setLogService(LogService logService) {
		this.logService = logService;
	}

	public DbService getDbService() {
		return dbService;
	}

	public void setDbService(DbService dbService) {
		this.dbService = dbService;
	}

	public File getFilePDF() {
		return filePDF;
	}

	public void setFilePDF(File filePDF) {
		this.filePDF = filePDF;
	}

	public File getFilePhoto() {
		return filePhoto;
	}

	public void setFilePhoto(File filePhoto) {
		this.filePhoto = filePhoto;
	}

	// ----------------------仪器送检记录管理部分--------------------------------------
	/**
	 * 保存送检记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @author Zhanxm
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void saveYiqisjjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqiid = getRequest().getParameter("yiqiid");
			String songjianrq = getRequest().getParameter("songjianrq");
			String songjianr = getRequest().getParameter("songjianr");
			String remark = getRequest().getParameter("remark");
			Yiqisjjl yiqisjjl = new Yiqisjjl();
			yiqisjjl.setSongjianrq(songjianrq);
			yiqisjjl.setSongjianr(songjianr);
			yiqisjjl.setYiqiid(Long.parseLong(yiqiid));
			yiqisjjl.setState("送检");
			yiqisjjl.setRemark(remark);
			yiqisjjl.setAddtime(PubMethod.getAddtime());
			epService.saveObject(yiqisjjl);

			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, Long.parseLong(yiqiid));
			equipment.setShiyongzt("送检");
			epService.saveObject(equipment);

			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 查询送检记录列表
	 */
	public void queryYiqisjjl() {
		try {
			String yiqilx = getRequest().getParameter("yiqilx");
			String yiqimc = getRequest().getParameter("yiqimc");
			String guigexh = getRequest().getParameter("guigexh");
			String state = getRequest().getParameter("state");
			Map<String, String> filterMap = getPagerMap();
			if (null != yiqilx && !"".equals(yiqilx)) {
				filterMap.put("yiqilx", StringUtil.encodingUrl(yiqilx));
			}
			if (null != yiqimc && !"".equals(yiqimc)) {
				filterMap.put("yiqimc", StringUtil.encodingUrl(yiqimc));
			}
			if (null != guigexh && !"".equals(guigexh)) {
				filterMap.put("guigexh", StringUtil.encodingUrl(guigexh));
			}
			if (null != state && !"".equals(state)) {
				filterMap.put("state", StringUtil.encodingUrl(state));
			}

			PageResult result = epService.queryYiqisjjl(filterMap);
			String[] viewArray = { "ID", "yiqimc", "guigexh", "zhizaocs",
					"zhizaobh", "songjianrq", "songjianr", "quhuirq", "quhuir",
					"xiacidjrq", "state" };
			String str = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 仪器初始化
	 * 
	 * @return
	 */
	public String toUpdateYiqisjjl() {
		String yiqisjjlid = getRequest().getParameter("yiqisjjlid");
		Yiqisjjl yiqisjjl = (Yiqisjjl) epService.getDataById(Yiqisjjl.class,
				Long.parseLong(yiqisjjlid));
		equipment = (TdmEquipment) epService.getDataById(TdmEquipment.class,
				yiqisjjl.getYiqiid());
		getRequest().setAttribute("yiqisjjlid", yiqisjjlid);
		getRequest().setAttribute("songjianrq", yiqisjjl.getSongjianrq());
		getRequest().setAttribute("songjianr", yiqisjjl.getSongjianr());
		getRequest().setAttribute("remark", yiqisjjl.getRemark());
		return "toUpdateYiqisjjl";
	}

	/**
	 * 更新送检记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void updateYiqisjjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqisjjlid = getRequest().getParameter("yiqisjjlid");
			String songjianrq = getRequest().getParameter("songjianrq");
			String songjianr = getRequest().getParameter("songjianr");
			String remark = getRequest().getParameter("remark");
			Yiqisjjl yiqisjjl = (Yiqisjjl) epService.getDataById(
					Yiqisjjl.class, Long.parseLong(yiqisjjlid));
			yiqisjjl.setSongjianrq(songjianrq);
			yiqisjjl.setSongjianr(songjianr);
			yiqisjjl.setRemark(remark);
			epService.updateObject(yiqisjjl);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 仪器初始化
	 * 
	 * @return
	 */
	public String toQuhuiYiqisjjl() {
		String yiqisjjlid = getRequest().getParameter("yiqisjjlid");
		Yiqisjjl yiqisjjl = (Yiqisjjl) epService.getDataById(Yiqisjjl.class,
				Long.parseLong(yiqisjjlid));
		equipment = (TdmEquipment) epService.getDataById(TdmEquipment.class,
				yiqisjjl.getYiqiid());
		getRequest().setAttribute("yiqisjjlid", yiqisjjlid);
		getRequest().setAttribute("quhuirq", yiqisjjl.getQuhuirq());
		getRequest().setAttribute("quhuir", yiqisjjl.getQuhuir());
		if (yiqisjjl.getJiandingbgid() == null) {
			getRequest().setAttribute("jiandingbgid", this.getID());
		} else {
			getRequest().setAttribute("jiandingbgid",
					yiqisjjl.getJiandingbgid());
		}
		getRequest().setAttribute("remark", yiqisjjl.getRemark());
		return "toQuhuiYiqisjjl";
	}

	/**
	 * 下载检定报告
	 * 
	 * @return
	 */
	public void downJiandingbg() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqisjjlid = getRequest().getParameter("yiqisjjlid");
			String strSql = "select t1.id from tdm_attachment t1 left join kl_yiqisjjl t2 on t1.code_id=t2.jiandingbgid where t2.id='"
					+ yiqisjjlid + "'";
			List lists = autoService.getDatabySql(strSql);
			if (lists.size() > 0) {
				out.print("{\"result\":\"success\",\"attachid\":\""
						+ lists.get(0).toString() + "\"}");
			} else {
				out.print("{\"result\":\"noexists\"}");
			}
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 更新送检记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void quhuiYiqisjjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqisjjlid = getRequest().getParameter("yiqisjjlid");
			String quhuirq = getRequest().getParameter("quhuirq");
			String quhuir = getRequest().getParameter("quhuir");
			String remark = getRequest().getParameter("remark");
			String jiandingbgid = getRequest().getParameter("jiandingbgid");
			String xiacidjrq = getRequest().getParameter("xiacidjrq");
			Yiqisjjl yiqisjjl = (Yiqisjjl) epService.getDataById(
					Yiqisjjl.class, Long.parseLong(yiqisjjlid));
			yiqisjjl.setQuhuirq(quhuirq);
			yiqisjjl.setQuhuir(quhuir);
			if (jiandingbgid != null && !jiandingbgid.equals("")) {
				yiqisjjl.setJiandingbgid(Long.parseLong(jiandingbgid));
			}
			yiqisjjl.setRemark(remark);
			yiqisjjl.setState("已取回");
			epService.updateObject(yiqisjjl);

			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, yiqisjjl.getYiqiid());
			equipment.setXiacidjrq(xiacidjrq);
			equipment.setShiyongzt("维护");
			epService.saveObject(equipment);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 删除设备台账信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Aug 3, 2015 3:40:32 PM
	 */
	public void deleteYiqisjjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String sbId = getRequest().getParameter("ids");
			String ids[] = sbId.split(",");

			for (String id : ids) {
				Yiqisjjl yiqisjjl = (Yiqisjjl) epService.getDataById(
						Yiqisjjl.class, Long.parseLong(id));
				epService.deleteData(yiqisjjl);
			}
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 仪器送检记录导出 void
	 * 
	 * @date Apr 21, 2015 2:18:05 PM
	 */
	public void exportYiqisjjlExcel() {
		String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH")
				.toString();
		String sourcefilepath = pathUrl + "/exportmb/仪器送检记录.xls";
		String targetfilepath = pathUrl + "/exporttemp/仪器送检记录.xls";
		File targetfile = new File(targetfilepath);
		if (targetfile.exists()) {
			targetfile.deleteOnExit();
		}

		try {
			copyFile(new File(sourcefilepath), new File(targetfilepath));
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		ExcelTool et = new ExcelTool(targetfilepath);
		try {
			String strSql = "select t1.id,t2.yiqimc,t2.guigexh,t2.zhizaocs,t2.zhizaobh,t1.songjianrq,t1.songjianr,"
					+ "t1.quhuirq,t1.quhuir,t2.xiacidjrq,t1.state,t1.remark from kl_yiqisjjl t1 left join kl_yiqi t2 on t1.yiqiid=t2.id ";
			List lists = autoService.getDatabySql(strSql);
			for (int i = 0; i < lists.size(); i++) {
				int rowIndex = 2 + i;
				Object[] objs = (Object[]) lists.get(i);
				et.SetCells(rowIndex, 1, objs[1].toString());
				et.SetCells(rowIndex, 2, objs[2].toString());
				et.SetCells(rowIndex, 3, objs[3].toString());
				et.SetCells(rowIndex, 4, objs[4].toString());
				et.SetCells(rowIndex, 5, objs[5].toString());
				et.SetCells(rowIndex, 6, objs[6].toString());
				et.SetCells(rowIndex, 7, objs[7].toString());
				et.SetCells(rowIndex, 8, objs[8].toString());
				et.SetCells(rowIndex, 9, objs[9].toString());
				et.SetCells(rowIndex, 10, objs[10].toString());
				et.SetCells(rowIndex, 11, objs[11].toString());
			}
			et.Save();
			exportFile(targetfilepath);
		} catch (Exception e) {
			et.Save();
			e.printStackTrace();
		}
	}

	// ----------------------仪器送检记录管理部分结束--------------------------------------

	// ----------------------仪器维修记录管理部分--------------------------------------
	/**
	 * 保存维修记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void saveYiqisxjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqiid = getRequest().getParameter("yiqiid");
			String songxiurq = getRequest().getParameter("songxiurq");
			String songxiur = getRequest().getParameter("songxiur");
			String remark = getRequest().getParameter("remark");
			Yiqisxjl yiqisxjl = new Yiqisxjl();
			yiqisxjl.setSongxiurq(songxiurq);
			yiqisxjl.setSongxiur(songxiur);
			yiqisxjl.setYiqiid(Long.parseLong(yiqiid));
			yiqisxjl.setState("维修");
			yiqisxjl.setRemark(remark);
			yiqisxjl.setAddtime(PubMethod.getAddtime());
			epService.saveObject(yiqisxjl);

			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, Long.parseLong(yiqiid));
			equipment.setShiyongzt("维修");
			epService.saveObject(equipment);

			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 查询送检记录列表
	 */
	public void queryYiqisxjl() {
		try {
			String yiqilx = getRequest().getParameter("yiqilx");
			String yiqimc = getRequest().getParameter("yiqimc");
			String guigexh = getRequest().getParameter("guigexh");
			String state = getRequest().getParameter("state");
			Map<String, String> filterMap = getPagerMap();
			if (null != yiqilx && !"".equals(yiqilx)) {
				filterMap.put("yiqilx", StringUtil.encodingUrl(yiqilx));
			}
			if (null != yiqimc && !"".equals(yiqimc)) {
				filterMap.put("yiqimc", StringUtil.encodingUrl(yiqimc));
			}
			if (null != guigexh && !"".equals(guigexh)) {
				filterMap.put("guigexh", StringUtil.encodingUrl(guigexh));
			}
			if (null != state && !"".equals(state)) {
				filterMap.put("state", StringUtil.encodingUrl(state));
			}

			PageResult result = epService.queryYiqisxjl(filterMap);
			String[] viewArray = { "ID", "yiqimc", "guigexh", "zhizaocs",
					"zhizaobh", "songxiurq", "songxiur", "quhuirq", "quhuir",
					"weixiujg", "state" };
			String str = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 仪器送修记录初始化
	 * 
	 * @return
	 */
	public String toUpdateYiqisxjl() {
		try {
			String yiqisxjlid = getRequest().getParameter("yiqisxjlid");
			Yiqisxjl yiqisxjl = (Yiqisxjl) epService.getDataById(
					Yiqisxjl.class, Long.parseLong(yiqisxjlid));
			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, yiqisxjl.getYiqiid());
			getRequest().setAttribute("yiqisxjlid", yiqisxjlid);
			getRequest().setAttribute("songxiurq", yiqisxjl.getSongxiurq());
			getRequest().setAttribute("songxiur", yiqisxjl.getSongxiur());
			getRequest().setAttribute("remark", yiqisxjl.getRemark());
			return "toUpdateYiqisxjl";
		} catch (Exception exp) {
			exp.printStackTrace();
			return "";
		}
	}

	/**
	 * 更新送修记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void updateYiqisxjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqisxjlid = getRequest().getParameter("yiqisxjlid");
			String songxiurq = getRequest().getParameter("songxiurq");
			String songxiur = getRequest().getParameter("songxiur");
			String remark = getRequest().getParameter("remark");
			Yiqisxjl yiqisxjl = (Yiqisxjl) epService.getDataById(
					Yiqisxjl.class, Long.parseLong(yiqisxjlid));
			yiqisxjl.setSongxiurq(songxiurq);
			yiqisxjl.setSongxiur(songxiur);
			yiqisxjl.setRemark(remark);
			epService.updateObject(yiqisxjl);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 初始化取回送修记录
	 * 
	 * @return
	 */
	public String toQuhuiYiqisxjl() {
		String yiqisxjlid = getRequest().getParameter("yiqisxjlid");
		Yiqisxjl yiqisxjl = (Yiqisxjl) epService.getDataById(Yiqisxjl.class,
				Long.parseLong(yiqisxjlid));
		equipment = (TdmEquipment) epService.getDataById(TdmEquipment.class,
				yiqisxjl.getYiqiid());
		getRequest().setAttribute("yiqisxjlid", yiqisxjlid);
		getRequest().setAttribute("quhuirq", yiqisxjl.getQuhuirq());
		getRequest().setAttribute("quhuir", yiqisxjl.getQuhuir());
		getRequest().setAttribute("weixiujg", yiqisxjl.getWeixiujg());
		getRequest().setAttribute("remark", yiqisxjl.getRemark());
		return "toQuhuiYiqisxjl";
	}

	/**
	 * 更新送修记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void quhuiYiqisxjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqisxjlid = getRequest().getParameter("yiqisxjlid");
			String quhuirq = getRequest().getParameter("quhuirq");
			String quhuir = getRequest().getParameter("quhuir");
			String weixiujg = getRequest().getParameter("weixiujg");
			String remark = getRequest().getParameter("remark");
			Yiqisxjl yiqisxjl = (Yiqisxjl) epService.getDataById(
					Yiqisxjl.class, Long.parseLong(yiqisxjlid));
			yiqisxjl.setQuhuirq(quhuirq);
			yiqisxjl.setQuhuir(quhuir);
			yiqisxjl.setWeixiujg(weixiujg);
			yiqisxjl.setRemark(remark);
			yiqisxjl.setState("已取回");
			epService.updateObject(yiqisxjl);
			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, yiqisxjl.getYiqiid());
			if (weixiujg.equals("已修好")) {
				equipment.setShiyongzt("维护");
			} else if (weixiujg.equals("未修好")) {
				equipment.setShiyongzt("报废");
			}
			epService.saveObject(equipment);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 删除送修记录
	 * 
	 * @throws Exception
	 *             void
	 * @date Aug 3, 2015 3:40:32 PM
	 */
	public void deleteYiqisxjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String sbId = getRequest().getParameter("ids");
			String ids[] = sbId.split(",");

			for (String id : ids) {
				Yiqisxjl yiqisxjl = (Yiqisxjl) epService.getDataById(
						Yiqisxjl.class, Long.parseLong(id));
				epService.deleteData(yiqisxjl);
			}
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 仪器送修记录导出 void
	 * 
	 * @date Apr 21, 2015 2:18:05 PM
	 */
	public void exportYiqisxjlExcel() {
		String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH")
				.toString();
		String sourcefilepath = pathUrl + "/exportmb/仪器送修记录.xls";
		String targetfilepath = pathUrl + "/exporttemp/仪器送修记录.xls";
		File targetfile = new File(targetfilepath);
		if (targetfile.exists()) {
			targetfile.deleteOnExit();
		}

		try {
			copyFile(new File(sourcefilepath), new File(targetfilepath));
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		ExcelTool et = new ExcelTool(targetfilepath);
		try {
			String strSql = "select t1.id,t2.yiqimc,t2.guigexh,t2.zhizaocs,t2.zhizaobh,t1.songxiurq,t1.songxiur,"
					+ "t1.quhuirq,t1.quhuir,t1.weixiujg,t1.state,t1.remark from kl_yiqisxjl t1 left join kl_yiqi t2 on t1.yiqiid=t2.id ";
			List lists = autoService.getDatabySql(strSql);
			for (int i = 0; i < lists.size(); i++) {
				int rowIndex = 2 + i;
				Object[] objs = (Object[]) lists.get(i);
				et.SetCells(rowIndex, 1, objs[1].toString());
				et.SetCells(rowIndex, 2, objs[2].toString());
				et.SetCells(rowIndex, 3, objs[3].toString());
				et.SetCells(rowIndex, 4, objs[4].toString());
				et.SetCells(rowIndex, 5, objs[5].toString());
				et.SetCells(rowIndex, 6, objs[6].toString());
				et.SetCells(rowIndex, 7, objs[7].toString());
				et.SetCells(rowIndex, 8, objs[8].toString());
				et.SetCells(rowIndex, 9, objs[9].toString());
				et.SetCells(rowIndex, 10, objs[10].toString());
				et.SetCells(rowIndex, 11, objs[11].toString());
			}
			et.Save();
			exportFile(targetfilepath);
		} catch (Exception e) {
			et.Save();
			e.printStackTrace();
		}
	}

	// ----------------------仪器维修记录管理部分结束--------------------------------------

	// ----------------------仪器借还记录管理部分--------------------------------------
	/**
	 * 保存维修记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void saveYiqijhjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqiid = getRequest().getParameter("yiqiid");
			String peitaofj = getRequest().getParameter("peitaofj");
			String jieyongdw = getRequest().getParameter("jieyongdw");
			String jieyongr = getRequest().getParameter("jieyongr");
			String jieyongrdh = getRequest().getParameter("jieyongrdh");
			String jiechurq = getRequest().getParameter("jiechurq");
			String yongtu = getRequest().getParameter("yongtu");
			String shiyongdd = getRequest().getParameter("shiyongdd");
			String jiechujbr = getRequest().getParameter("jiechujbr");
			String state = getRequest().getParameter("state");
			String remark = getRequest().getParameter("remark");
			Yiqijhjl yiqijhjl = new Yiqijhjl();
			yiqijhjl.setYiqiid(Long.parseLong(yiqiid));
			yiqijhjl.setPeitaofj(peitaofj);
			yiqijhjl.setJieyongdw(jieyongdw);
			yiqijhjl.setJieyongr(jieyongr);
			yiqijhjl.setJieyongrdh(jieyongrdh);
			yiqijhjl.setJiechurq(jiechurq);
			yiqijhjl.setYongtu(yongtu);
			yiqijhjl.setShiyongdd(shiyongdd);
			yiqijhjl.setJiechujbr(jiechujbr);
			yiqijhjl.setState("借出");
			yiqijhjl.setRemark(remark);
			epService.saveObject(yiqijhjl);

			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, Long.parseLong(yiqiid));
			equipment.setShiyongzt("借出");
			epService.saveObject(equipment);

			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 查询送检记录列表
	 */
	public void queryYiqijhjl() {
		try {
			String yiqilx = getRequest().getParameter("yiqilx");
			String yiqimc = getRequest().getParameter("yiqimc");
			String guigexh = getRequest().getParameter("guigexh");
			String state = getRequest().getParameter("state");
			Map<String, String> filterMap = getPagerMap();
			if (null != yiqilx && !"".equals(yiqilx)) {
				filterMap.put("yiqilx", StringUtil.encodingUrl(yiqilx));
			}
			if (null != yiqimc && !"".equals(yiqimc)) {
				filterMap.put("yiqimc", StringUtil.encodingUrl(yiqimc));
			}
			if (null != guigexh && !"".equals(guigexh)) {
				filterMap.put("guigexh", StringUtil.encodingUrl(guigexh));
			}
			if (null != state && !"".equals(state)) {
				filterMap.put("state", StringUtil.encodingUrl(state));
			}

			PageResult result = epService.queryYiqijhjl(filterMap);
			String[] viewArray = { "ID", "yiqimc", "guigexh", "zhizaocs",
					"zhizaobh", "peitaofj", "jieyongdw", "jieyongr",
					"jieyongrdh", "jiechurq", "yongtu", "shiyongdd",
					"jiechujbr", "guihuanrq", "guihuanr", "guihuanjbr", "state" };
			String str = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 仪器送修记录初始化
	 * 
	 * @return
	 */
	public String toUpdateYiqijhjl() {
		try {
			String yiqijhjlid = getRequest().getParameter("yiqijhjlid");
			Yiqijhjl yiqijhjl = (Yiqijhjl) epService.getDataById(
					Yiqijhjl.class, Long.parseLong(yiqijhjlid));
			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, yiqijhjl.getYiqiid());
			getRequest().setAttribute("yiqijhjlid", yiqijhjlid);
			getRequest().setAttribute("peitaofj", yiqijhjl.getPeitaofj());
			getRequest().setAttribute("jieyongdw", yiqijhjl.getJieyongdw());
			getRequest().setAttribute("jieyongr", yiqijhjl.getJieyongr());
			getRequest().setAttribute("jieyongrdh", yiqijhjl.getJieyongrdh());
			getRequest().setAttribute("jiechurq", yiqijhjl.getJiechurq());
			getRequest().setAttribute("yongtu", yiqijhjl.getYongtu());
			getRequest().setAttribute("shiyongdd", yiqijhjl.getShiyongdd());
			getRequest().setAttribute("jiechujbr", yiqijhjl.getJiechujbr());
			getRequest().setAttribute("remark", yiqijhjl.getRemark());
			return "toUpdateYiqijhjl";
		} catch (Exception exp) {
			exp.printStackTrace();
			return "";
		}
	}

	/**
	 * 更新送修记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void updateYiqijhjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqijhjlid = getRequest().getParameter("yiqijhjlid");
			;
			String peitaofj = getRequest().getParameter("peitaofj");
			String jieyongdw = getRequest().getParameter("jieyongdw");
			String jieyongr = getRequest().getParameter("jieyongr");
			String jieyongrdh = getRequest().getParameter("jieyongrdh");
			String jiechurq = getRequest().getParameter("jiechurq");
			String yongtu = getRequest().getParameter("yongtu");
			String shiyongdd = getRequest().getParameter("shiyongdd");
			String jiechujbr = getRequest().getParameter("jiechujbr");
			String remark = getRequest().getParameter("remark");
			Yiqijhjl yiqijhjl = (Yiqijhjl) epService.getDataById(
					Yiqijhjl.class, Long.parseLong(yiqijhjlid));
			yiqijhjl.setPeitaofj(peitaofj);
			yiqijhjl.setJieyongdw(jieyongdw);
			yiqijhjl.setJieyongr(jieyongr);
			yiqijhjl.setJieyongrdh(jieyongrdh);
			yiqijhjl.setJiechurq(jiechurq);
			yiqijhjl.setYongtu(yongtu);
			yiqijhjl.setShiyongdd(shiyongdd);
			yiqijhjl.setJiechujbr(jiechujbr);
			yiqijhjl.setRemark(remark);
			epService.updateObject(yiqijhjl);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 初始化取回送修记录
	 * 
	 * @return
	 */
	public String toQuhuiYiqijhjl() {
		String yiqijhjlid = getRequest().getParameter("yiqijhjlid");
		Yiqijhjl yiqijhjl = (Yiqijhjl) epService.getDataById(Yiqijhjl.class,
				Long.parseLong(yiqijhjlid));
		equipment = (TdmEquipment) epService.getDataById(TdmEquipment.class,
				yiqijhjl.getYiqiid());
		getRequest().setAttribute("yiqijhjlid", yiqijhjlid);
		getRequest().setAttribute("guihuanrq", yiqijhjl.getGuihuanrq());
		getRequest().setAttribute("guihuanr", yiqijhjl.getGuihuanr());
		getRequest().setAttribute("guihuanjbr", yiqijhjl.getGuihuanjbr());
		getRequest().setAttribute("remark", yiqijhjl.getRemark());
		return "toQuhuiYiqijhjl";
	}

	/**
	 * 更新送修记录信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void quhuiYiqijhjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String yiqijhjlid = getRequest().getParameter("yiqijhjlid");
			String guihuanrq = getRequest().getParameter("guihuanrq");
			String guihuanr = getRequest().getParameter("guihuanr");
			String guihuanjbr = getRequest().getParameter("guihuanjbr");
			String remark = getRequest().getParameter("remark");
			Yiqijhjl yiqijhjl = (Yiqijhjl) epService.getDataById(
					Yiqijhjl.class, Long.parseLong(yiqijhjlid));
			yiqijhjl.setGuihuanjbr(guihuanjbr);
			yiqijhjl.setGuihuanr(guihuanr);
			yiqijhjl.setGuihuanrq(guihuanrq);
			yiqijhjl.setRemark(remark);
			yiqijhjl.setState("已归还");
			epService.updateObject(yiqijhjl);
			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, yiqijhjl.getYiqiid());
			equipment.setShiyongzt("维护");
			epService.saveObject(equipment);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 删除送修记录
	 * 
	 * @throws Exception
	 *             void
	 * @date Aug 3, 2015 3:40:32 PM
	 */
	public void deleteYiqijhjl() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String sbId = getRequest().getParameter("ids");
			String ids[] = sbId.split(",");

			for (String id : ids) {
				Yiqijhjl yiqijhjl = (Yiqijhjl) epService.getDataById(
						Yiqijhjl.class, Long.parseLong(id));
				epService.deleteData(yiqijhjl);
			}
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 仪器送修记录导出 void
	 * 
	 * @date Apr 21, 2015 2:18:05 PM
	 */
	public void exportYiqijhjlExcel() {
		String pathUrl = getRequest().getSession().getAttribute("SYS_FILEPATH")
				.toString();
		String sourcefilepath = pathUrl + "/exportmb/仪器借还记录.xls";
		String targetfilepath = pathUrl + "/exporttemp/仪器借还记录.xls";
		File targetfile = new File(targetfilepath);
		if (targetfile.exists()) {
			targetfile.deleteOnExit();
		}

		try {
			copyFile(new File(sourcefilepath), new File(targetfilepath));
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		ExcelTool et = new ExcelTool(targetfilepath);
		try {
			String strSql = "select t1.id,t2.yiqimc,t2.guigexh,t2.zhizaocs,t2.zhizaobh,t1.peitaofj,t1.jieyongdw,"
					+ "t1.jieyongr,t1.jieyongrdh,t1.jiechurq,t1.yongtu,t1.shiyongdd,"
					+ "t1.jiechujbr,t1.guihuanrq,t1.guihuanr,t1.guihuanjbr,t1.state,t1.remark"
					+ " from kl_yiqijhjl t1 left join kl_yiqi t2 on t1.yiqiid=t2.id ";
			List lists = autoService.getDatabySql(strSql);
			for (int i = 0; i < lists.size(); i++) {
				int rowIndex = 2 + i;
				Object[] objs = (Object[]) lists.get(i);
				et.SetCells(rowIndex, 1, objs[1].toString());
				et.SetCells(rowIndex, 2, objs[2].toString());
				et.SetCells(rowIndex, 3, objs[3].toString());
				et.SetCells(rowIndex, 4, objs[4].toString());
				et.SetCells(rowIndex, 5, objs[5].toString());
				et.SetCells(rowIndex, 6, objs[6].toString());
				et.SetCells(rowIndex, 7, objs[7].toString());
				et.SetCells(rowIndex, 8, objs[8].toString());
				et.SetCells(rowIndex, 9, objs[9].toString());
				et.SetCells(rowIndex, 10, objs[10].toString());
				et.SetCells(rowIndex, 11, objs[11].toString());
				et.SetCells(rowIndex, 12, objs[12].toString());
				et.SetCells(rowIndex, 13, objs[13] == null ? "" : objs[13]
						.toString());
				et.SetCells(rowIndex, 14, objs[14] == null ? "" : objs[14]
						.toString());
				et.SetCells(rowIndex, 15, objs[15] == null ? "" : objs[15]
						.toString());
				et.SetCells(rowIndex, 16, objs[16] == null ? "" : objs[16]
						.toString());
				et.SetCells(rowIndex, 17, objs[17] == null ? "" : objs[17]
						.toString());
			}
			et.Save();
			exportFile(targetfilepath);
		} catch (Exception e) {
			et.Save();
			e.printStackTrace();
		}
	}

	// ----------------------仪器借还记录管理部分结束--------------------------------------

	// ----------------------仪器管理部分------------------------------------------------
	/**
	 * 仪器初始化
	 * 
	 * @return
	 */
	public String toAddEquMain() {
		String org_id = getRequest().getParameter("org_id");
		String org_name = StringUtil.encodingUrl(getRequest().getParameter(
				"org_name"));
		String sbId = getRequest().getParameter("sbId");
		if (null != sbId && !"".equals(sbId)) {
			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, Long.parseLong(sbId));
			getRequest().setAttribute("equipment", equipment);
		}
		getRequest().setAttribute("equipmentid", getID());
		getRequest().setAttribute("org_id", org_id);
		getRequest().setAttribute("org_name", org_name);
		return "toAddEquMain";
	}

	/**
	 * 跳转到设备台账修改页面
	 * 
	 * @return String
	 * @author Zhanxm
	 * @date Jul 31, 2015 4:55:21 PM
	 */
	public String toUpdateEquMain() {
		try {
			String sbId = getRequest().getParameter("sbId");
			String actiontype = getRequest().getParameter("actiontype");
			equipment = (TdmEquipment) epService.getDataById(
					TdmEquipment.class, Long.parseLong(sbId));
			getRequest().setAttribute("tequipment", equipment);
			getRequest().setAttribute("actiontype", actiontype);
			return "toUpdateEquMain";
		} catch (Exception exp) {
			exp.printStackTrace();
			return "toUpdateEquMain";
		}
	}

	/**
	 * 保存设备基本信息台账
	 * 
	 * @throws Exception
	 *             void
	 * @author Zhanxm
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void saveYiqi() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			equipment.setAddtime(PubMethod.getAddtime());
			epService.saveObject(equipment);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 更新设备基本信息台账
	 * 
	 * @throws Exception
	 *             void
	 * @author Zhanxm
	 * @date Jul 29, 2015 5:21:40 PM
	 */
	public void updateYiqi() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			epService.updateObject(equipment);
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 删除设备台账信息
	 * 
	 * @throws Exception
	 *             void
	 * @date Aug 3, 2015 3:40:32 PM
	 */
	public void deleteYiqi() throws Exception {
		PrintWriter out = getResponse().getWriter();
		try {
			String sbId = getRequest().getParameter("ids");
			String deltype = getRequest().getParameter("deltype");
			String ids[] = sbId.split(",");
			if (deltype.equals("del")) {
				for (String id : ids) {
					equipment = (TdmEquipment) epService.getDataById(
							TdmEquipment.class, Long.parseLong(id));
					epService.deleteData(equipment);
				}
			} else {
				for (String id : ids) {
					equipment = (TdmEquipment) epService.getDataById(
							TdmEquipment.class, Long.parseLong(id));
					equipment.setShiyongzt("报废");
					epService.updateObject(equipment);
				}
			}
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 设备导出 void
	 * 
	 * @date Apr 21, 2015 2:18:05 PM
	 */
	public void exportYiqiExcel() {
		try {
			String pathUrl = getRequest().getSession().getAttribute(
					"SYS_FILEPATH").toString();
			String sourcefilepath = pathUrl + "/exportmb/仪器信息.xls";
			String targetfilepath = pathUrl + "/exporttemp/仪器信息.xls";
			File targetfile = new File(targetfilepath);
			if (targetfile.exists()) {
				targetfile.deleteOnExit();
			}

			copyFile(new File(sourcefilepath), new File(targetfilepath));
			ExcelTool et = new ExcelTool(targetfilepath);
			String strSql = "select * from kl_yiqi ";
			List lists = autoService.getDatabySql(strSql);
			for (int i = 0; i < lists.size(); i++) {
				int rowIndex = 2 + i;
				Object[] objs = (Object[]) lists.get(i);
				et.SetCells(rowIndex, 1, objs[1].toString());
				et.SetCells(rowIndex, 2, objs[2].toString());
				et.SetCells(rowIndex, 3, objs[3].toString());
				et.SetCells(rowIndex, 4, objs[4].toString());
				et.SetCells(rowIndex, 5, objs[5].toString());
				et.SetCells(rowIndex, 6, objs[6].toString());
				et.SetCells(rowIndex, 7, objs[7].toString());
				et.SetCells(rowIndex, 8, objs[8].toString());
				et.SetCells(rowIndex, 9, objs[9].toString());
				et.SetCells(rowIndex, 10, objs[11].toString());
				et.SetCells(rowIndex, 11, objs[12].toString());
				et.SetCells(rowIndex, 12, objs[13].toString());
				et.SetCells(rowIndex, 13, objs[14].toString());
				et.SetCells(rowIndex, 14, objs[15].toString());
				et.SetCells(rowIndex, 15, objs[16].toString());
				et.SetCells(rowIndex, 16, objs[17].toString());
				et.SetCells(rowIndex, 17, objs[18].toString());
			}
			et.Save();
			exportFile(targetfilepath);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 仪器列表zr
	 */
	public void queryEquipmentListkl() {
		try {
			String yiqilx = getRequest().getParameter("yiqilx");
			String yiqimc = getRequest().getParameter("yiqimc");
			String guigexh = getRequest().getParameter("guigexh");
			String zhizaocs = getRequest().getParameter("zhizaocs");
			String zhizaobh = getRequest().getParameter("zhizaobh");
			String fuzher = getRequest().getParameter("fuzher");
			String org_id = getRequest().getParameter("org_id");
			String type = getRequest().getParameter("type");
			Map<String, String> filterMap = getPagerMap();
			if (null != yiqilx && !"".equals(yiqilx)) {
				filterMap.put("yiqilx", StringUtil.encodingUrl(yiqilx));
			}
			if (null != yiqimc && !"".equals(yiqimc)) {
				filterMap.put("yiqimc", StringUtil.encodingUrl(yiqimc));
			}
			if (null != guigexh && !"".equals(guigexh)) {
				filterMap.put("guigexh", StringUtil.encodingUrl(guigexh));
			}
			if (null != zhizaocs && !"".equals(zhizaocs)) {
				filterMap.put("zhizaocs", StringUtil.encodingUrl(zhizaocs));
			}
			if (null != zhizaobh && !"".equals(zhizaobh)) {
				filterMap.put("zhizaobh", StringUtil.encodingUrl(zhizaobh));
			}
			if (null != fuzher && !"".equals(zhizaobh)) {
				filterMap.put("fuzher", StringUtil.encodingUrl(fuzher));
			}
			if (null != org_id && !"".equals(org_id)) {
				filterMap.put("org_id", org_id);
			}
			if (null != type && !"".equals(type)) {
				filterMap.put("type", type);
			}

			PageResult result = epService.queryEquipmentList(filterMap);
			String[] viewArray = { "ID", "YIQILX", "YIQIMC", "GUIGEXH",
					"ZHIZAOCS", "ZHIZAOBH", "JINGDUDJ", "CELIANGFW",
					"GOUMAIRQ", "ZHERENR", "SUOSHUBMMC", "SHIYONGDW",
					"JIANDINGZQ", "XIACIDJRQ", "TIXINGTS", "DAOQIZT",
					"SHIYONGZT", "SHIYONGCS" };
			String str = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 导入仪器基本信息
	 * 
	 * @return String
	 * @date Apr 20, 2015 2:22:38 PM
	 */
	public void importExcelData() throws IOException {
		PrintWriter out = getResponse().getWriter();
		try {
			// 实例化一个工作簿对象
			Workbook workBook = Workbook.getWorkbook(filePath);
			// 获取该工作表中的第一个工作表
			Sheet sheet = workBook.getSheet(0);
			// 获取该工作表的行数，以供下面循环使用
			int rowSize = sheet.getRows();
			if (rowSize < 2) {
				out.print("{\"result\":\"error\"}");
				out.flush();
				out.close();
			}
			for (int i = 1; i < rowSize; i++) {
				String yiqilx = sheet.getCell(0, i).getContents();
				String yiqimc = sheet.getCell(1, i).getContents();
				String guigexh = sheet.getCell(2, i).getContents();
				String zhizaocs = sheet.getCell(3, i).getContents();
				String zhizaobh = sheet.getCell(4, i).getContents();
				String jingdudj = sheet.getCell(5, i).getContents();
				String celiangfw = sheet.getCell(6, i).getContents();
				String goumairq = sheet.getCell(7, i).getContents();
				String zherenr = sheet.getCell(8, i).getContents();
				String suoshubmmc = sheet.getCell(9, i).getContents();
				String shiyongdw = sheet.getCell(10, i).getContents();
				String jiandingzq = sheet.getCell(11, i).getContents();
				String xiacidjrq = sheet.getCell(12, i).getContents();
				String tixingts = sheet.getCell(13, i).getContents();
				String daoqizt = sheet.getCell(14, i).getContents();
				String shiyongzt = sheet.getCell(15, i).getContents();
				String shiyongcs = sheet.getCell(16, i).getContents();
				if (yiqilx != null && !yiqilx.equals("")) {
					TdmEquipment tequipment = new TdmEquipment();
					tequipment.setYiqilx(yiqilx);
					tequipment.setYiqimc(yiqimc);
					tequipment.setGuigexh(guigexh);
					tequipment.setZhizaocs(zhizaocs);
					tequipment.setZhizaobh(zhizaobh);
					tequipment.setJingdudj(jingdudj);
					tequipment.setCeliangfw(celiangfw);
					tequipment.setGoumairq(goumairq);
					tequipment.setZherenr(zherenr);
					tequipment.setSuoshubmmc(suoshubmmc);
					tequipment.setSuoshubmid(getOrgIdByName(suoshubmmc));
					tequipment.setShiyongdw(shiyongdw);
					tequipment.setJiandingzq(jiandingzq);
					tequipment.setXiacidjrq(xiacidjrq);
					if (!tixingts.equals("")) {
						tequipment.setTixingts(Long.parseLong(tixingts));
					}
					tequipment.setDaoqizt(daoqizt);
					tequipment.setShiyongzt(shiyongzt);
					if (!shiyongcs.equals("")) {
						tequipment.setShiyongcs(Long.parseLong(shiyongcs));
					}

					epService.saveObject(tequipment);
				}
			}
			addMessage("导入成功！");
			out.print("{\"result\":\"success\"}");
			out.flush();
			out.close();
		} catch (Exception ex) {
			ex.printStackTrace();
			out.print("{\"result\":\"error\"}");
			out.flush();
			out.close();
		}
	}

	public String getFieldTypeNoChild(List fieldNameList, List fieldTypeList,
			List pageDisplayTypeList, int cols, String formId,
			List<String> excelTitle) throws IOException {
		for (int j = 0; j < cols; j++) {
			// 获取单元格标题
			String fieldCnName = excelTitle.get(j);
			// 查询主表字段名称、字段类型
			String strSQL = "select t.field_name,t.field_type,t.PAGE_DISPLAY_TYPE from auto_forms_field t "
					+ "where t.forms_id='"
					+ formId
					+ "'and t.cn_name='"
					+ fieldCnName + "'";
			List<Object[]> list = autoService.getDatabySql(strSQL);
			if (list.size() == 0) {
				String msg="数据库表中没有"+fieldCnName+"字段";
				return msg;
				//return -1;
				//fieldNameList.add(null);
				//fieldTypeList.add(null);
				//pageDisplayTypeList.add(null);
			} else {
				Object[] data = list.get(0);
				String fieldName = (String) data[0];
				String fieldType = (String) data[1];
				fieldNameList.add(fieldName);
				fieldTypeList.add(fieldType);
				if (data[2] == null) {
					pageDisplayTypeList.add(null);
				} else {
					String pageDisplayType = data[2].toString();
					pageDisplayTypeList.add(pageDisplayType);
				}			
			}
		}
		return "success";
		//return 0;
	}
	public String getFieldTypeSingle(String fieldname,String formId)
	{
		String type="";
		// 查询主表字段名称、字段类型
		String sql = "select t.field_type from auto_forms_field t "
				+ "where t.forms_id='"+ formId+"' and t.field_name='"+
				fieldname+"'";
		List<String> list=dbService.queryDataBySql(sql);
		if(list.size()!=0&&list.get(0)!=null)
		{
			type=list.get(0).toString();
		}		
		return type;
	}
	public String getFieldTypeHasChild(List fieldNameList, List fieldTypeList,List pageDisplayTypeList,
			List fieldNameListChild, List fieldTypeListChild,List pageDisplayTypeListChild, int cols,
			String formId, String formIdChild, List<String> excelTitle)
			throws IOException {
		int filedNotFind[]=new int[cols];
		
		for (int j = 0; j < cols; j++) {
			filedNotFind[j]=0;
			// 获取单元格标题
			String fieldCnName = excelTitle.get(j);
			// 查询主表字段名称、字段类型
			String strSQL = "select t.field_name,t.field_type,t.PAGE_DISPLAY_TYPE from auto_forms_field t "
					+ "where t.forms_id='"
					+ formId
					+ "'and t.cn_name='"
					+ fieldCnName + "'";
			List<Object[]> list = autoService.getDatabySql(strSQL);
			if (list.size() == 0) {	
				filedNotFind[j]++;
				fieldNameList.add(null);
				fieldTypeList.add(null);
				pageDisplayTypeList.add(null);
			} else {
				Object[] data = list.get(0);
				String fieldName = (String) data[0];
				String fieldType = (String) data[1];
				fieldNameList.add(fieldName);
				fieldTypeList.add(fieldType);
				if (data[2] == null) {
					pageDisplayTypeList.add(null);
				} else {
					String pageDisplayType = data[2].toString();
					pageDisplayTypeList.add(pageDisplayType);
				}
			}
			// 查询子表字段名称、字段类型
			String strSQLChild = "select t.field_name,t.field_type,t.PAGE_DISPLAY_TYPE from auto_forms_field t "
					+ "where t.forms_id='"
					+ formIdChild
					+ "'and t.cn_name='"
					+ fieldCnName + "'";
			List databySql = autoService.getDatabySql(strSQLChild);
			List<Object[]> listChild = databySql;
			if (listChild.size() == 0) {
				filedNotFind[j]++;
				if(filedNotFind[j]==2)
				{
					String msg="数据库表中没有"+fieldCnName+"字段";
					//JOptionPane.showMessageDialog(null, msg, "错误提示", JOptionPane.ERROR_MESSAGE); 					
					//return -1;
					return msg;
				}
				fieldNameListChild.add(null);
				fieldTypeListChild.add(null);
				pageDisplayTypeListChild.add(null);
			} else {
				Object[] data = listChild.get(0);
				String fieldName = (String) data[0];
				String fieldType = (String) data[1];
				fieldNameListChild.add(fieldName);
				fieldTypeListChild.add(fieldType);
				if (data[2] == null) {
					pageDisplayTypeListChild.add(null);
				} else {
					String pageDisplayType = data[2].toString();
					pageDisplayTypeListChild.add(pageDisplayType);
				}
			}	
		}
		return "success";
		//return 0;
	}

	
//	public void getFieldTypeHasChild(List fieldNameList, List fieldTypeList,
//			List fieldNameListChild, List fieldTypeListChild, int cols,
//			String formId, String formIdChild, List<String> excelTitle)
//			throws IOException {
//		for (int j = 0; j < cols; j++) {
//			// 获取单元格标题
//			String fieldCnName = excelTitle.get(j);
//			// 查询主表字段名称、字段类型
//			String strSQL = "select t.field_name,t.field_type from auto_forms_field t "
//					+ "where t.forms_id='"
//					+ formId
//					+ "'and t.cn_name='"
//					+ fieldCnName + "'";
//			List<Object[]> list = autoService.getDatabySql(strSQL);
//			if (list.size() == 0) {
//				fieldNameList.add(null);
//				fieldTypeList.add(null);
//			} else {
//				Object[] data = list.get(0);
//				String fieldName = (String) data[0];
//				String fieldType = (String) data[1];
//				fieldNameList.add(fieldName);
//				fieldTypeList.add(fieldType);
//			}
//			// 查询子表字段名称、字段类型
//			String strSQLChild = "select t.field_name,t.field_type from auto_forms_field t "
//					+ "where t.forms_id='"
//					+ formIdChild
//					+ "'and t.cn_name='"
//					+ fieldCnName + "'";
//			List databySql = autoService.getDatabySql(strSQLChild);
//			List<Object[]> listChild = databySql;
//			if (listChild.size() == 0) {
//				fieldNameListChild.add(null);
//				fieldTypeListChild.add(null);
//			} else {
//				Object[] data = listChild.get(0);
//				String fieldName = (String) data[0];
//				String fieldType = (String) data[1];
//				fieldNameListChild.add(fieldName);
//				fieldTypeListChild.add(fieldType);
//			}
//		}
//	}
	public String changeDateValue(String strValue)throws IOException 
	{
		String strFieldValue;
		if(strValue.equals("不详")||strValue.equals("/"))
		{
			strFieldValue = ",''";
		}
		else
		{
			try{
				double day=Double.parseDouble(strValue);
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");  
				//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");      	 
		        String  str = sdf.format(HSSFDateUtil.getJavaDate(day)).toString();
				strFieldValue = ",to_date('";
				strFieldValue += str;
				strFieldValue += "','YYYY/MM/DD')";
			}
			catch(Exception e)
			{
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); 
				try {
					sdf.parse(strValue);
					strFieldValue = ",to_date('";
					strFieldValue += strValue;
					strFieldValue += "','YYYY/MM/DD')";
				} catch (ParseException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
					String msg="日期转换失败："+e1.getMessage();
					return msg;
				}	
			}  
		}	
		return strFieldValue;
	}
	public String changeFieldValue(String strValue, String fieldType)
			throws IOException {
		// 判断数据类型是否为日期类型
		if (fieldType.equals("DATE") && !strValue.equals("")) {
			if(strValue.equals("不详"))
			{
				strFieldValue = ",''";
			}
			else
			{
				try{
					double day=Double.parseDouble(strValue);
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");  
					//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");      	 
			        String  str = sdf.format(HSSFDateUtil.getJavaDate(day)).toString();
					strFieldValue = ",to_date('";
					strFieldValue += str;
					strFieldValue += "','YYYY/MM/DD')";
				}
				catch(Exception e)
				{
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); 
					try {
						sdf.parse(strValue);
						strFieldValue = ",to_date('";
						strFieldValue += strValue;
						strFieldValue += "','YYYY/MM/DD')";
					} catch (ParseException e1) {
						// TODO Auto-generated catch block
						SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); 
						try {
							sdf2.parse(strValue);
							strFieldValue = ",to_date('";
							strFieldValue += strValue;
							strFieldValue += "','YYYY/MM/DD')";
						} catch (ParseException e2) {
							e2.printStackTrace();
							return e2.getMessage();
						}
					}	
				}  
			}		
		}
		// 数值类型
		else if (fieldType.equals("NUMBER")) {
			strValue = strValue.replace("E", "").replace("N", "").replace("W",
					"").replace("S", "");
			strFieldValue = "," + strValue;
		} else {
			strFieldValue = ",'" + strValue + "'";
		}
		return "success";
	}

	/**
	 * 导入仪器基本信息
	 * 
	 * @return String
	 * @date Apr 20, 2015 2:22:38 PM
	 */

	public void uploadfile(List filepathlist) throws IOException {
		int num = filepathlist.size();
		String annexIds = "";
		String[] allAnnexId = null;
		for (int i = 0; i < num; i++) {
			// String fileName = (String) getUploadfileFileName().get(i);
			// String fileType =
			// fileName.substring((fileName.lastIndexOf("."))+1,
			// fileName.length());
			String fileName = "20160818.txt";
			String fileType = "txt";
			File ff = new File(filepathlist.get(i).toString());
			if (ff.length() > 0) {
				ActionContext ac = ActionContext.getContext();
				ServletContext sc = (ServletContext) ac
						.get(ServletActionContext.SERVLET_CONTEXT);
				String url = getRequest().getSession().getAttribute(
						"SYS_FILEPATH").toString();
				SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
						"yyyyMM");
				String date = simpleDateFormat.format(new Date());
				url = url + "/annex/" + date;
				File file = new File(url);
				if (!(file.exists()) && !(file.isDirectory())) {
					boolean creadok = file.mkdirs();
					if (creadok) {
						System.out.println(" ok:创建文件夹成功！ ");
					} else {
						System.out.println(" err:创建文件夹失败！ ");
					}
				}
				String address = url + "/" + fileName;
				// String address = url + "/" + getUploadfileFileName().get(i);
				FileOutputStream fos = new FileOutputStream(address);
				FileInputStream fis = new FileInputStream(filepathlist.get(i)
						.toString());
				byte[] buffer = new byte[1024];
				int len = 0;
				while ((len = fis.read(buffer)) > 0) {
					fos.write(buffer, 0, len);
				}
				fos.close();
				fis.close();
				// 将附件保存到Tdm_annex中
				// TdmAnnex annex = new TdmAnnex();
				// annex.setFileName(getUploadfileFileName().get(i).toString());
				// annex.setFilePath("/annex/"+date+"/" +
				// getUploadfileFileName().get(i));
				// annex.setAnnexType(1l);
				// annex.setCreateTime(new Date());
				// annex.setCreateUserid(Long.parseLong(this.getUserId()));
				// annex.setCreateUsername(this.getUserName());
				// String annexId = autoService.saveObject(annex);
				// annexIds = annexIds +","+annexId;
			}
		}
		if (!"".equals(annexIds)) {
			annexIds = annexIds.substring(1);
			allAnnexId = annexIds.split(",");
		}
	}

	// public void uploadfile(List filepathlist)throws IOException{
	// String id = GenerateSequenceUtil.generateSequenceNo();
	// String path="<%=path%>/FileUploadServlet?saveDataId=saveDataId1";
	// URL url = new URL(path);
	//
	// url.openStream();
	//
	// //sb.append("<a href='auto!toUploadcontrol.action?fileid="+id+"'
	// target='_blank'>文件上传</a>");
	// //sb.append("<input type=\"hidden\" id=\""+field.getFieldName()+"\"
	// name=\""+field.getFieldName()+"\" class=\"button_b\" value='"+id+"' />");
	// }

	public static void unZipFiles(File zipFile, String descDir)
			throws IOException {
		File pathFile = new File(descDir);
		if (!pathFile.exists()) {
			pathFile.mkdirs();
		}
		ZipFile zip = new ZipFile(zipFile);
		for (Enumeration entries = zip.getEntries(); entries.hasMoreElements();) {
			ZipEntry entry = (ZipEntry) entries.nextElement();
			String zipEntryName = entry.getName();
			InputStream in = zip.getInputStream(entry);
			int index = zipEntryName.indexOf("/");
			String path = zipEntryName.substring(index + 1, zipEntryName
					.length());
			String outPath = (descDir + path).replace("/", "\\");
			//String outPath = (descDir + path).replaceAll("\\*", "/");
			// String outPath = (descDir+zipEntryName).replaceAll("\\*", "/");;
			// 判断路径是否存在,不存在则创建文件路径
			//File file = new File(outPath.substring(0, outPath.lastIndexOf('/')));
			File file = new File(outPath.substring(0, outPath.lastIndexOf('\\')));
			if (!file.exists()) {
				file.mkdirs();
			}
			// 判断文件全路径是否为文件夹,如果是上面已经上传,不需要解压
			if (new File(outPath).isDirectory()) {
				continue;
			}
			// 输出文件路径信息
			OutputStream out = new FileOutputStream(outPath);
			byte[] buf1 = new byte[1024];
			int len;
			while ((len = in.read(buf1)) > 0) {
				out.write(buf1, 0, len);
			}
			in.close();
			out.close();
		}
		zip.close();
	}
//	public void uploadAttachment() throws IOException {
//		// 获取文件名称
//		String filenamePDF = getRequest().getParameter("filenamePDF");
//		String filenamePhoto = getRequest().getParameter("filenamePhoto");
//		if(filenamePDF.equals("")&&filenamePhoto.equals(""))
//		{
//			return;
//		}
//		// 获取存储目录
//		String ctxDir = getRequest().getSession().getServletContext()
//				.getInitParameter("filePath");
//		if (!ctxDir.endsWith(String.valueOf(File.separatorChar))) {
//			ctxDir = ctxDir + File.separatorChar;
//		}
//		//每天上传的文件根据日期存放在不同的文件夹
//		String autoCreatedDateDirByParttern = "yyyy" + File.separatorChar + "MM" + File.separatorChar + "dd"
//				+ File.separatorChar;
//		String autoCreatedDateDir = DateFormatUtils.format(new java.util.Date(), autoCreatedDateDirByParttern);
//		
//		// 文件保存位置，当前项目下的upload/attachment
//		String uploadDir = "upload" + File.separatorChar + "attachment"
//				+ File.separatorChar;
//		File savePath = new File(ctxDir + uploadDir + autoCreatedDateDir);
//		if (!savePath.exists()) {
//			savePath.mkdirs();
//		}
//		String saveDirectory = ctxDir + uploadDir + autoCreatedDateDir;
//	
//		if (filenamePDF != null && !filenamePDF.equals("")) {
//			// 移动PDF
//			File fileDesPDF = new File(saveDirectory + filenamePDF);
//			filePDF.renameTo(fileDesPDF);
//			// 解压PDF
//			int index=filenamePDF.indexOf(".");
//			String filenamePDFLeft=filenamePDF.substring(0,index);
//			String desPDFDir = saveDirectory + filenamePDFLeft+File.separatorChar;
//			unZipFiles(fileDesPDF, desPDFDir);
//		}
//		if (filenamePhoto != null && !filenamePhoto.equals("")) {
//			// 移动照片
//			File fileDesPhoto = new File(saveDirectory + filenamePhoto);
//			filePhoto.renameTo(fileDesPhoto);
//			// 解压照片
//			//String desPhotoDir = ctxDir + uploadDir + "Photo/";
//			int index=filenamePhoto.indexOf(".");
//			String filenamePhotoLeft=filenamePhoto.substring(0,index);
//			String desPhotoDir = saveDirectory + filenamePhotoLeft+File.separatorChar;
//			unZipFiles(fileDesPhoto, desPhotoDir);
//		}
//	}
	public String getUploadAttachmentDir() throws IOException {
		// 获取存储目录
		String ctxDir = getRequest().getSession().getServletContext()
				.getInitParameter("filePath");
		if (!ctxDir.endsWith(String.valueOf(File.separatorChar))) {
			ctxDir = ctxDir + File.separatorChar;
		}
		//每天上传的文件根据日期存放在不同的文件夹
		String autoCreatedDateDirByParttern = "yyyy" + File.separatorChar + "MM" + File.separatorChar + "dd"
				+ File.separatorChar;
		String autoCreatedDateDir = DateFormatUtils.format(new java.util.Date(), autoCreatedDateDirByParttern);
		
		// 文件保存位置，当前项目下的upload/attachment
		String uploadDir = "upload" + File.separatorChar + "attachment"
				+ File.separatorChar;
		String saveDirectory = ctxDir + uploadDir + autoCreatedDateDir;
		return saveDirectory;
	}
	public String getDesDir(String filename,String saveDirectory) throws IOException {
		if(filename.equals("")||filename==null)
		{
			return "";
		}
		int index=filename.indexOf(".");
		String filenamePDFLeft=filename.substring(0,index);
		String id = GenerateSequenceUtil.generateSequenceNo();
		//String desPDFDir = saveDirectory + filenamePDFLeft+File.separatorChar;
		String desPDFDir = saveDirectory + filenamePDFLeft+id+File.separatorChar;
		return desPDFDir;
	}
	public String uploadAttachment(String filenamePDF,String filenamePhoto,String saveDirectory,
			String desPDFDir,String desPhotoDir) throws IOException {
		File savePath = new File(saveDirectory);
		if (!savePath.exists()) {
			savePath.mkdirs();
		}
		if (filenamePDF != null && !filenamePDF.equals("")) {
			// 移动PDF
			File fileDesPDF = new File(saveDirectory + filenamePDF);
			if(fileDesPDF.exists())
			{
				String msg=filenamePDF+"文件已存在,请选择其他PDF文件！";
				return msg;
			}
			filePDF.renameTo(fileDesPDF);
			// 解压PDF			
			unZipFiles(fileDesPDF, desPDFDir);
			//删除压缩包
			fileDesPDF.delete();
		}
		if (filenamePhoto != null && !filenamePhoto.equals("")) {
			// 移动照片
			File fileDesPhoto = new File(saveDirectory + filenamePhoto);
			if(fileDesPhoto.exists())
			{
				String msg=filenamePhoto+"文件已存在,请选择其他照片文件！";
				return msg;
			}
			filePhoto.renameTo(fileDesPhoto);
			// 解压照片		
			unZipFiles(fileDesPhoto, desPhotoDir);
			//删除压缩包
			fileDesPhoto.delete();
		}
		return "success";
	}
	public boolean isRowRepeat(String tableName,String uniquefield,ExcelTool et,int cols,int i,List fieldNameList,StringBuffer repeatValue)
	{
		Boolean isRepeat=false;
		if(uniquefield==null)
		{
			return isRepeat;
		}
		for (int j = 0; j < cols; j++) {
			String fieldName = (String) fieldNameList.get(j);
			// 获取单元格
			String strValue =et.GetCells(1,i + 1, j + 1);
			if(fieldName!=null&&fieldName.equals(uniquefield))
			{
				String sql="select "+uniquefield+" from "+tableName;
				List<String> uniquevalues=autoService.getDatabySql(sql);
				int valuenum=uniquevalues.size();
				for(int k=0;k<valuenum;k++)
				{
					if(strValue.equals(uniquevalues.get(k)))
					{
						repeatValue.append(strValue);
						isRepeat=true;
						break;
					}
				}
			}
		}
		return isRepeat;
	}
	// 导入含有子表的excel文件
	public String importPersonDataHasChild(String formId, String formIdChild,
			ExcelTool et, int rowSize, int cols,String desPDFDir,String desPhotoDir,String formCnName) 
		throws IOException, Exception{
		List<String> lists = new ArrayList<String>();
		// 获取主表名称
		String strSql = "select form_en_name from auto_forms_new where id='"
				+ formId + "'";
		List tableList = autoService.getDatabySql(strSql);
		String tableName = tableList.get(0).toString();
		// 获取子表名称
		List tableListChild;
		String tableNameChild = null;
		List filecnnameListChild;
		int fieldNumChild = 0;	
		strSql = "select form_en_name from auto_forms_new where id='"
				+ formIdChild + "'";
		tableListChild = autoService.getDatabySql(strSql);
		tableNameChild = tableListChild.get(0).toString();
		// 获取子表各字段中文名称
		strSql = "select t.cn_name,t.field_name,t.field_type from auto_forms_field t where t.Field_Name<>'ID'"
				+ " and  t.forms_id='"
				+ formIdChild
				+ "' order by t.show_seq";
		filecnnameListChild = autoService.getDatabySql(strSql);
		// 获取子表字段个数
		fieldNumChild = filecnnameListChild.size();	
		// 查询字段名称、字段类型
		List fieldNameList = new ArrayList<String>();
		List fieldTypeList = new ArrayList<String>();
		List pageDisplayTypeList = new ArrayList<String>();
		// 子表字段名称、字段类型
		List fieldNameListChild = new ArrayList<String>();
		List fieldTypeListChild = new ArrayList<String>();
		List pageDisplayTypeListChild = new ArrayList<String>();
		
		// 获取单元格标题
		List<String> excelTitleList = new ArrayList<String>();
		for (int j = 0; j < cols; j++) {
			String fieldCnName = et.GetCellText(1, j + 1);
			if(fieldCnName!=null&&!fieldCnName.equals(""))
			{
				excelTitleList.add(fieldCnName);
			}			
		}
		// 获取字段类型
		int fieldNum=excelTitleList.size();
		String res=getFieldTypeHasChild(fieldNameList, fieldTypeList,pageDisplayTypeList,
				fieldNameListChild,fieldTypeListChild, pageDisplayTypeListChild,
				fieldNum, formId, formIdChild, excelTitleList);
		if(!res.equals("success"))
		{
			return res;
		}
		cols=excelTitleList.size();
		// 读取附件列
		res=readAttachmentColHasChild(et,cols,rowSize, 
				pageDisplayTypeList,pageDisplayTypeListChild,
				fieldNameList,fieldNameListChild,desPDFDir,desPhotoDir);
		if(!res.equals("success"))
		{
			return res;
		}
		//获取唯一性字段
		String sql="select t.UNIQUEFIELD from auto_forms_new t where t.id='"+formId + "'";
		List<String> uniquefieldList = autoService.getDatabySql(sql);
		String uniquefield=uniquefieldList.get(0);
		sql="select t.UNIQUEFIELD from auto_forms_new t where t.id='"+formIdChild + "'";
		List<String> uniquefieldListChild = autoService.getDatabySql(sql);
		String uniquefieldChild=uniquefieldListChild.get(0);
		//唯一字段中文名	
		String uniquefieldCn="";
		if(uniquefieldChild!=null)
		{
			sql="select t.CN_NAME from auto_forms_field t where t.forms_id='"+formId + "'";
			sql+=" and t.FIELD_NAME='"+uniquefield+"'";
			List<String> uniquefieldCnList = autoService.getDatabySql(sql);
			if(uniquefieldCnList.size()!=0&&uniquefieldCnList.get(0)!=null)
			{
				uniquefieldCn=uniquefieldCnList.get(0);
			}
		}
		// 每行数据插入数据库
		int successrownum=0;
		int emptyrownum=0;
		String mainTableId = "";
		String strPipeLineNo = "";
		String strTaskNo = "";
		String strPipeNo = "";
		String fieldnames = "";
		int mainCols=fieldNameList.size();
		for (int j = 0; j < fieldNum; j++) {
			// 获取字段名称、字段数据类型
			String fieldName = (String) fieldNameList.get(j);
			String fieldType = (String) fieldTypeList.get(j);
			if (fieldName == null) {
				continue;
			}
			// 更新管线编号
			fieldnames += "," + fieldName;
		}
		List<String> repeatList=new ArrayList();
		boolean isMainFailed=false;
		for (int i = 1; i < rowSize; i++) {	
			//判断是否重复
 			Boolean isRepeat=false;
 			StringBuffer repeatValue=new StringBuffer();
 			isRepeat=isRowRepeat(tableName, uniquefield, et, cols, i, fieldNameList,repeatValue);
 			if(isRepeat==true)
 			{
 				String repeatMsg="第"+(i+1)+"行中的"+uniquefieldCn+repeatValue.toString()+"已存在";
 				repeatList.add(repeatValue.toString());
 				logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",repeatMsg,4);
 				continue;
 			}			
			String fieldnamesChild = "";
			String values = "";
			String valuesChild = "";
			// 组合主表的values
			int emptyFieldNum = 0;
			List<String> valuelist=new ArrayList();
			List<String> valuelistChild=new ArrayList();			
			String firstValue=et.GetCellText(i + 1, 1);
				for (int j = 0; j < fieldNum; j++) {
				// 获取字段名称、字段数据类型
				String fieldName = (String) fieldNameList.get(j);
				if (fieldName == null) {
					continue;
				}
				String fieldType = (String) fieldTypeList.get(j);
				String pageDisplayType = "";
				if (pageDisplayTypeList.get(j) != null) {
					pageDisplayType = (String) pageDisplayTypeList.get(j);
				}	
				// 获取列标
				String colName=et.GetColumnNameLarge(j+1);
				// 获取单元格 
				String strValue = et.GetCellText(i + 1, j + 1);		
				// 去掉前后空格
				strValue = strValue.trim();
				// 单元格中内容为空、“不详”或“/”
				if (strValue.equals("null")||strValue==null||strValue.equals("")
						|| strValue.equals("/")) {
					emptyFieldNum++;					
					if (pageDisplayType.equals("13")) {
						String id = GenerateSequenceUtil.generateSequenceNo();						
						values += ",'" + id + "'";
						valuelist.add(id);
						continue;
					}
					else  if(!fieldType.equals("VARCHAR2"))
					{
						values += ",''";
						valuelist.add("");
						continue;
					}
					
					//continue;
				}
				// 更新管线编号
				if (fieldName.equals("PIPELINENO")&&!strValue.equals("")) {
					strPipeLineNo = strValue;
				}
				// 更新任务编号
				if (fieldName.equals("TASKNO")&&!strValue.equals("")) {
					strTaskNo = strValue;
				}
				// 更管网编号
				if (fieldName.equals("PIPENO")&&!strValue.equals("")) {
					strPipeNo = strValue;
				}
				// 根据字段类型设置字段值
				changeFieldValue(strValue, fieldType);	
				// 附件类型
				if (pageDisplayType.equals("13")) {
					String id = GenerateSequenceUtil.generateSequenceNo();
					values += ",'" + id + "'";
					valuelist.add(id);
					int pointindex=strValue.lastIndexOf(".");
					if(!strValue.equals("")&&!strValue.equals("/")&&pointindex!=-1)
					{
						sql="insert into PTEM_ATTACHMENT(ID,code_id,file_name)" +
						"values(SEQ_PTEM_ATTACHMENT.nextval,"+id+",'";
						sql+=strValue+"')";
						dbService.exeSql(sql);
						//res=attachmentToDb(strValue,id,desPDFDir,desPhotoDir);
						String filenames[]=strValue.split("；");
						int filenum=filenames.length;
						for(int k=0;k<filenum;k++)
						{
							res=attachmentToDb(filenames[k],id,desPDFDir,desPhotoDir);	
							if(!res.equals("success"))
							{
								boolean isError=true;
								res="第"+(i+1)+"行"+"第"+colName+"列"+"附件插入数据库失败："+res;
								logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",res,4);
								continue;
							}
						}
//						if(!res.equals("success"))
//						{
//							return res;
//						}
					}	
					else
					{
						if(strValue.equals(""))
						{
							emptyFieldNum++;
						}
					}
				} else {
					values += strFieldValue;
					valuelist.add(strFieldValue.substring(1,strFieldValue.length()));
				}		
			}
			//if (emptyFieldNum != fieldNumMain)
			
			if (!firstValue.equals(""))				
			{
				// 插入主表
				String asql = "SEQ_" + tableName + ".nextval";				
				strSql = "insert into " + tableName + "(ID" + fieldnames + ")"
						+ "values(" + asql + values + ")";
				try {
					autoService.executeSql(strSql);
					isMainFailed=false;
				}
				catch (Exception e){
					isMainFailed=true;
					String msg=e.getCause().getLocalizedMessage();		
					if(msg.indexOf("ORA-00984: 列在此处不允许")!=-1)
					{
						String fieldnamestemp=fieldnames.substring(1,fieldnames.length());
						String[]  fieldnameArr=fieldnamestemp.split(",");
						int numtemp=fieldnameArr.length;
						for (int j = 0; j <numtemp ; j++) {
							String fieldName=fieldnameArr[j];
							// 获取字段名称、字段数据类型			
							String fieldType = getFieldTypeSingle(fieldName,formId);	
							String val=valuelist.get(j);
							val=val.trim();
							if(fieldType.equals("NUMBER")&&!val.equals("''")&&!val.equals(""))
							{							
								try{
									Double db=Double.valueOf(val);
								}
								catch(Exception e1){
									String log="第"+(i+1)+"行"+excelTitleList.get(j)+"应为数值";
									logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);								
									continue;
								}
							}
						}
					}
					else
					{
						String log="第"+(i+1)+"行插入失败："+msg;
						logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);										
					}
				}		
				strSql="select max((cast(id as int))) from "+tableName;
				List<Object> idList=dbService.queryDataBySql(strSql);
				if(idList.get(0)!=null)
				{
					mainTableId=idList.get(0).toString();
				}				
			}			
//			if(mainTableId.equals(""))
//			{
//				continue;
//			}
//			//判断是否重复 			
// 			isRepeat=isRowRepeat(tableNameChild, uniquefieldChild, et, cols, i, fieldNameListChild);
// 			if(isRepeat==true)
// 			{
// 				continue;
// 			}		
			// 组合子表的values
			int emptyFieldNumChild = 0;
			int childCol=fieldNameListChild.size();
			int realchildcol=childCol;
			for (int j = 0; j < childCol; j++) {
				// 获取字段名称、字段数据类型
				String fieldName = (String) fieldNameListChild.get(j);
				if (fieldName == null) {
					realchildcol--;
					continue;
				}
				String fieldType = (String) fieldTypeListChild.get(j);
				String pageDisplayType = "";
				if (pageDisplayTypeListChild.get(j) != null) {
					pageDisplayType = (String) pageDisplayTypeListChild.get(j);
				}				
				// 获取单元格
				String strValue = et.GetCellText(i + 1, j + 1);
				// 单元格中内容为空、“不详”或“/”
				if (strValue.equals("") || strValue.equals("不详")
						|| strValue.equals("/")) {
					emptyFieldNumChild++;
					if (
							!fieldName.equals("PIPELINENO")
							&& !fieldName.equals("TASKNO")
							&& !fieldName.equals("PIPENO")) {
						
						if(!fieldType.equals("VARCHAR2")&&
						   !fieldName.equals("PIPELINENO")&&
						   !fieldName.equals("TASKNO")&&
						   !fieldName.equals("PIPENO"))
						{
							fieldnamesChild += "," + fieldName;
							valuesChild += ",''";
							continue;
						}
						//continue;
					}
				}
				fieldnamesChild += "," + fieldName;
				// 根据字段类型设置字段值
				// 更新管线编号
				if (fieldName.equals("PIPELINENO")) {
					changeFieldValue(strPipeLineNo, fieldType);
				}
				// 更新任务编号
				else if (fieldName.equals("TASKNO")) {
					changeFieldValue(strTaskNo, fieldType);
				}
				// 更新管网编号
				else if (fieldName.equals("PIPENO")) {
					changeFieldValue(strPipeNo, fieldType);
				} else {
					changeFieldValue(strValue, fieldType);
				}				
				// 附件类型
				if (pageDisplayType.equals("13")) {
					String id = GenerateSequenceUtil.generateSequenceNo();
					valuesChild += ",'" + id + "'";
					valuelistChild.add(id);
					if(!strValue.equals("")&&!strValue.equals("/"))
					{
						res=attachmentToDb(strValue,id,desPDFDir,desPhotoDir);
						if(!res.equals("success"))
						{
							return res;
						}
					}
					else
					{
						if(strValue.equals(""))
						{
							//emptyFieldNumChild++;
						}
					}
				} else {
					valuesChild += strFieldValue;
					valuelistChild.add(strFieldValue.substring(1,strFieldValue.length()));
				}		
			}
			if(mainTableId.equals("")||(isMainFailed==true))
			{				
				if(i==337)
				{
					System.out.print("i");
				}
				int emptyNum=emptyFieldNum+emptyFieldNumChild;
				if(emptyNum==cols)
				{
					emptyrownum++;
				}		
				continue;
			}
			
			if(emptyFieldNumChild!=realchildcol)
			{
				fieldnamesChild += ",PARENTID";
				valuesChild += ",";
				valuesChild += mainTableId;
				valuelistChild.add(mainTableId);
				String idChild = "SEQ_" + tableNameChild + ".nextval";
				strSql = "insert into " + tableNameChild + "(ID" + fieldnamesChild
						+ ")" + "values(" + idChild + valuesChild + ")";
				try {
					autoService.executeSql(strSql);
					successrownum++;
				}
				catch (Exception e){
					String msg=e.getCause().getLocalizedMessage();		
					if(msg.indexOf("ORA-00984: 列在此处不允许")!=-1)
					{
						for (int j = 0; j < cols; j++) {
							// 获取字段名称、字段数据类型			
							String fieldType = (String) fieldTypeListChild.get(j);	
							String val=valuelistChild.get(j);
							val=val.trim();
							if(fieldType.equals("NUMBER")&&!val.equals("''")&&!val.equals(""))
							{							
								try{
									Double db=Double.valueOf(val);
								}
								catch(Exception e1){
									String log="第"+(i+1)+"行"+excelTitleList.get(j)+"应为数值";
									logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);								
									continue;
								}
							}
						}
					}
					else
					{
						String log="第"+(i+1)+"行插入失败："+msg;
						logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);										
					}					
				//autoService.executeSql(strSql);
				}	
			}
//			if(i==337)
//			{
//				System.out.print("i");
//			}
			int emptyNum=emptyFieldNum+emptyFieldNumChild;
			if(emptyNum==cols)
			{
				emptyrownum++;
			}			
		}
		if(successrownum<(rowSize-1-emptyrownum))
 		{
 			int failrownum=rowSize-1-successrownum-emptyrownum;
 			String msg=successrownum+"行导入成功，"+failrownum+"行导入失败。失败原因请查看日志！";
 			return msg;	
 		}	
		return "success";	
		//return 0;
	}
	public String attachmentToDb(String strValue,String id,String desPDFDir,String desPhotoDir) throws IOException {
		// 文件保存位置，当前项目下的upload/attachment
		TdmAttachment tdmAttachment = new TdmAttachment();
		tdmAttachment.setFileName(strValue);
		tdmAttachment.setFileDesc("这是描述");		
		//String fileType=strValue.substring(strValue.length()-3,strValue.length());
		int pointindex=strValue.lastIndexOf(".");
		String fileType=strValue.substring(pointindex+1,strValue.length());
		String fileSavePath="";
		//if(fileType.equals("pdf"))
		if(fileType.equals("pdf")||fileType.equals("doc")||fileType.equals("docx"))
		{
			if(desPDFDir.equals(""))
			{
				String msg="未选择PDF文件";
				return msg;
			}
			else
			{
				fileSavePath=desPDFDir + strValue;
			}
		}
		else 
		{
			if(desPhotoDir.equals(""))
			{
				String msg="未选择照片";
				return msg;
			}
			else
			{
				fileSavePath=desPhotoDir + strValue;
			}													
		}	
		String filePathReal=fileSavePath;
		int index=fileSavePath.indexOf("\\");
		fileSavePath=fileSavePath.substring(index,fileSavePath.length());
		// 获取存储目录
		String ctxDir = getRequest().getSession().getServletContext()
				.getInitParameter("filePath");
		if (!ctxDir.endsWith(String.valueOf(File.separatorChar))) {
			ctxDir = ctxDir + File.separatorChar;
		}		
		//String filePathReal=ctxDir+fileSavePath;
		File file = new File(filePathReal);
		tdmAttachment.setFileLength(String.valueOf(file.length()));
		tdmAttachment.setFilePath(fileSavePath);
		if (!StringUtil.isEmpty(id)) {
			tdmAttachment.setCodeId(new BigDecimal(id));
		}
		tdmAttachment.setCreateTime(new Timestamp(System
				.currentTimeMillis()));
		tdmAttachment.setCreateUserid(new BigDecimal(getRequest()
				.getSession().getAttribute("TDM_USER_ID")
				.toString()));
		tdmAttachment.setCreateUsername(getRequest().getSession()
				.getAttribute("username").toString());
		String ID = "";
		// 保存到数据库
		try {
			WebApplicationContext factory = WebApplicationContextUtils
					.getRequiredWebApplicationContext(getRequest()
							.getSession().getServletContext());
			TdmAttachmentService tdmAttachmentService = (TdmAttachmentService) factory
					.getBean("tdmAttachmentService");
			ID = tdmAttachmentService
					.saveAttachement(tdmAttachment);
		} catch (DaoException e) {
			e.printStackTrace();
		}
		return "success";
	}
	//获取唯一性字段
	public String getUniqueField(String formId) throws IOException, Exception 
	{
		String sql="select t.UNIQUEFIELD from auto_forms_new t where t.id='"+formId + "'";
		List<String> uniquefieldList = autoService.getDatabySql(sql);
		String uniquefield=uniquefieldList.get(0);
		return uniquefield;
	}
	//获取唯一字段中文名
	public String getUniqueFieldCn(String formId,String uniquefield) throws IOException, Exception 
	{
		String sql="select t.CN_NAME from auto_forms_field t where t.forms_id='"+formId + "'";
		sql+=" and t.FIELD_NAME='"+uniquefield+"'";
		List<String> uniquefieldCnList = autoService.getDatabySql(sql);
		String uniquefieldCn=uniquefieldCnList.get(0);
		return uniquefieldCn;
	}
	public String readAttachmentCol(ExcelTool et,int cols,int rowSize,List pageDisplayTypeList,
			List fieldNameList,String desPDFDir,String desPhotoDir)
	{
		String res="success";
		for (int j = 0; j < cols; j++) {
			String  displaytype=pageDisplayTypeList.get(j).toString();
			String  fieldName = (String) fieldNameList.get(j);
			if(fieldName==null)
			{
				continue;
			}
			if(displaytype.equals("13"))
			{
				for (int i = 1; i < rowSize; i++) {
					String strValue =et.GetCellText(i+1, j+1);
					strValue=strValue.trim();
					int indexPoint=strValue.indexOf(".");
					if(!strValue.equals("")&&(indexPoint!=-1))
					{
						boolean isPhoto=false;
						if(fieldName.equals("PHOTO")||
								fieldName.equals("GRAPH")||
								fieldName.equals("RADIOGRAPHIC")||
								fieldName.equals("METALLOGRAPHICALPHOTO")||
								fieldName.equals("TESTPOINTGRAPH")||
								fieldName.equals("PIPELINEGRAPH")||
								fieldName.equals("DIAGRAM")||
								fieldName.equals("CORROSIONPHOTO")||
								fieldName.equals("TESTDATAGRAPH")||
								fieldName.equals("PHOTOS")||
								fieldName.equals("DAMAGEDPOINTGRAPH")||
								fieldName.equals("TESTPOINTGROUPH")||
								fieldName.equals("PHOTONAME")||
								fieldName.equals("PHOTONAMES"))
						{
							isPhoto=true;
						}
						if(fieldName.equals("ATTACHMENT")&&desPDFDir.equals(""))
						{							
							res="请选择附件";
							return res;
						}
						//else if(fieldName.equals("PHOTO")&&desPhotoDir.equals(""))
						
						else if(isPhoto&&desPhotoDir.equals(""))
						{
							res="请选择照片";
							return res;
						}						
					}
				}
			}
		}
		return res;
	}
	public String readAttachmentColHasChild(ExcelTool et,int cols,int rowSize,
			List pageDisplayTypeList, List pageDisplayTypeListChild,
			List fieldNameList,List fieldNameListChild,
			String desPDFDir,String desPhotoDir)
	{
		String res="success";
		String displaytype="";
		String fieldName="";		
		for (int j = 0; j < cols; j++) {
			if(pageDisplayTypeList.get(j)==null||fieldNameList.get(j)==null)
			{
				continue;
			}			
			displaytype=pageDisplayTypeList.get(j).toString();
			fieldName = (String) fieldNameList.get(j);
			if(displaytype.equals("13"))
			{
				
				boolean isPhoto=false;
				if(fieldName.equals("PHOTO")||
						fieldName.equals("GRAPH")||
						fieldName.equals("RADIOGRAPHIC")||
						fieldName.equals("METALLOGRAPHICALPHOTO")||
						fieldName.equals("TESTPOINTGRAPH")||
						fieldName.equals("PIPELINEGRAPH")||
						fieldName.equals("DIAGRAM")||
						fieldName.equals("CORROSIONPHOTO")||
						fieldName.equals("TESTDATAGRAPH")||
						fieldName.equals("PHOTOS")||
						fieldName.equals("DAMAGEDPOINTGRAPH")||
						fieldName.equals("TESTPOINTGROUPH")||
						fieldName.equals("PHOTONAME")||
						fieldName.equals("PHOTONAMES"))
				{
					isPhoto=true;
				}
				for (int i = 1; i < rowSize; i++) {
					String strValue =et.GetCellText(i+1, j+1);
					strValue=strValue.trim();
					int indexPoint=strValue.indexOf(".");
					if(!strValue.equals("")&&(indexPoint!=-1))
					{
						if(fieldName.equals("ATTACHMENT")&&desPDFDir.equals(""))
						{							
							res="请选择附件";
							return res;
						}
						else if(isPhoto&&desPhotoDir.equals(""))
						{
							res="请选择照片";
							return res;
						}						
					}
				}
			}
			if(pageDisplayTypeList.get(j)==null||fieldNameList.get(j)==null)
			{
				continue;
			}	
		}
		for (int j = 0; j < cols; j++) {
			if(pageDisplayTypeListChild.get(j)==null||fieldNameListChild.get(j)==null)
			{
				continue;
			}	
			displaytype=pageDisplayTypeListChild.get(j).toString();
			fieldName = fieldNameListChild.get(j).toString();
			if(displaytype.equals("13"))
			{
				for (int i = 1; i < rowSize; i++) {
					String strValue =et.GetCellText(i+1, j+1);
					strValue=strValue.trim();
					if(!strValue.equals(""))
					{
						if(fieldName.equals("ATTACHMENT")&&desPDFDir.equals(""))
						{							
							res="请选择附件";
							return res;
						}
						else if(fieldName.equals("PHOTO")&&desPhotoDir.equals(""))
						{
							res="请选择照片";
							return res;
						}						
					}
				}
			}
		}
		return res;
	}
	
	// 导入不含子表的excel文件
	public String importPersonDataNoChild(String formId, ExcelTool et,
			int rowSize, int cols,String desPDFDir,String desPhotoDir,String formCnName) 
		throws IOException, Exception {
		List<String> lists = new ArrayList<String>();
		// 获取主表名称
		String strSql = "select form_en_name from auto_forms_new where id='"
				+ formId + "'";
		List tableList = autoService.getDatabySql(strSql);
		String tableName = tableList.get(0).toString();
		// 获取主表各字段中文名称
		strSql = "select t.cn_name,t.field_name,t.field_type,t.PAGE_DISPLAY_TYPE from auto_forms_field t where t.Field_Name<>'ID'"
				+ " and  t.forms_id='" + formId + "' order by t.show_seq";
		List filecnnameList = autoService.getDatabySql(strSql);
		// 获取主表字段个数
		int fieldNumMain = filecnnameList.size();
		// 查询字段名称、字段类型
		List fieldNameList = new ArrayList<String>();
		List fieldTypeList = new ArrayList<String>();
		List pageDisplayTypeList = new ArrayList<String>();
		// 获取单元格标题
		List<String> excelTitleList = new ArrayList<String>();
		for (int j = 0; j < cols; j++) {
			String fieldCnName = et.GetCellText(1, j + 1);
			//excelTitleList.add(fieldCnName);
			if(fieldCnName!=null&&!fieldCnName.equals(""))
			{
				excelTitleList.add(fieldCnName);
			}			
		}		
		cols=excelTitleList.size();
		// 获取字段类型
		String res=getFieldTypeNoChild(fieldNameList, fieldTypeList, pageDisplayTypeList,
				cols, formId, excelTitleList);
		if(!res.equals("success"))
		{
			return res;
		}
		// 读取附件列
		res=readAttachmentCol(et,cols,rowSize, pageDisplayTypeList,
				fieldNameList,desPDFDir,desPhotoDir);
		if(!res.equals("success"))
		{
			return res;
		}
		//获取唯一性字段
		String uniquefield=getUniqueField(formId);
		String uniquefieldCn="";
		if(uniquefield!=null&&!uniquefield.equals(""))
		{
			//唯一字段中文名
			uniquefieldCn=getUniqueFieldCn(formId,uniquefield);
		}	
		//组合字段名称
		String fieldnames = "";
		for (int j = 0; j < cols; j++) {
			// 获取字段名称、字段数据类型
			String fieldName = (String) fieldNameList.get(j);
			if (fieldName == null) {
				continue;
			}
			// 更新管线编号
			fieldnames += "," + fieldName;
		}
		// 每行数据插入数据库
		int successrownum=0;
		int emptyrownum=0;
 		for (int i = 1; i < rowSize; i++) {
 			boolean isError=false;
 			//判断是否重复
// 			Boolean isRepeat=false;
// 			StringBuffer repeatValue=new StringBuffer();
// 			isRepeat=isRowRepeat(tableName, uniquefield, et, cols, i, fieldNameList,repeatValue);
// 			if(isRepeat==true)
// 			{
// 				isError=true;
// 				String repeatMsg="第"+(i+1)+"行中的"+uniquefieldCn+repeatValue.toString()+"已存在"; 			
// 				logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",repeatMsg,4);				
// 				continue;
// 			}
			String values = "";
			// 组合主表的values
			int emptyFieldNum = 0;
			List<String> valuelist=new ArrayList();
			for (int j = 0; j < cols; j++) {
				// 获取字段名称、字段数据类型
				String fieldName = (String) fieldNameList.get(j);				
				String fieldType = (String) fieldTypeList.get(j);				
				String pageDisplayType = "";
				if (pageDisplayTypeList.get(j) != null) {
					pageDisplayType = (String) pageDisplayTypeList.get(j);
				}
				if (fieldName == null) {
					continue;
				}
				// 获取单元格内容
				String strValue="";								
				strValue =et.GetCellText(i + 1, j + 1);	
				// 获取列标
				String colName=et.GetColumnNameLarge(j+1);
				// 去掉前后空格
				strValue = strValue.trim();
				// 单元格中内容为空、“不详”或“/”		
				if ((!pageDisplayType.equals("13"))&&
						(strValue.equals("null")||strValue==null||
						 strValue.equals("")||strValue.equals("/"))) {
					
						if(!fieldType.equals("VARCHAR2"))
						{
							emptyFieldNum++;
							values += ",''";
							valuelist.add("");
							continue;
						}
						else
						{
							emptyFieldNum++;
						}
					}
				// 根据字段类型设置字段值
				res=changeFieldValue(strValue, fieldType);
				if(!res.equals("success"))
				{
					isError=true;					
					res="第"+(i+1)+"行"+"第"+colName+"列"+"有误："+res;
					logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",res,4);
					continue;
				}
				// 附件类型
				if (pageDisplayType.equals("13")) {
					String id = GenerateSequenceUtil.generateSequenceNo();
					values += ",'" + id + "'";
					valuelist.add("id");
					int pointindex=strValue.lastIndexOf(".");
					if(!strValue.equals("")&&!strValue.equals("/")&&pointindex!=-1)
					{		
						String sql="insert into PTEM_ATTACHMENT(ID,code_id,file_name)" +
						"values(SEQ_PTEM_ATTACHMENT.nextval,"+id+",'";
						sql+=strValue+"')";
						dbService.exeSql(sql);
						//res=attachmentToDb(strValue,id,desPDFDir,desPhotoDir);	
						String filenames[]=strValue.split("；");
						int filenum=filenames.length;
						for(int k=0;k<filenum;k++)
						{
							res=attachmentToDb(filenames[k],id,desPDFDir,desPhotoDir);	
							if(!res.equals("success"))
							{
								isError=true;
								res="第"+(i+1)+"行"+"第"+colName+"列"+"附件插入数据库失败："+res;
								logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",res,4);
								continue;
							}
						}
					}
					else
					{
						if(strValue.equals(""))
						{
							emptyFieldNum++;
						}
					}
				} else {
					values += strFieldValue;
					valuelist.add(strFieldValue.substring(1,strFieldValue.length()));
				}
			}
			if(emptyFieldNum==cols){
				emptyrownum++;
				continue;
			}
			if (emptyFieldNum != fieldNumMain) {
				String asql = "SEQ_" + tableName + ".nextval";
				if(isError==true) //有错误的不执行插入
				{
					continue;
				}
				strSql = "insert into " + tableName + "(ID" + fieldnames + ")"
						+ "values(" + asql + values + ")";
				try{
					autoService.executeSql(strSql);
					successrownum++;
				}
				catch(Exception e){	
					String msg=e.getCause().getLocalizedMessage();		
					if(msg.indexOf("ORA-00984: 列在此处不允许")!=-1||
					   msg.indexOf("ORA-00911: 无效字符")!=-1			
					)
					{
						for (int j = 0; j < cols; j++) {
							// 获取字段名称、字段数据类型			
							String fieldType = (String) fieldTypeList.get(j);	
							String val=valuelist.get(j);
							val=val.trim();
							if(fieldType.equals("NUMBER")&&!val.equals("''")&&!val.equals(""))
							{							
								try{
									Double db=Double.valueOf(val);
								}
								catch(Exception e1){
									String log="第"+(i+1)+"行"+excelTitleList.get(j)+"应为数值";
									logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);								
									continue;
								}
							}
						}	
					}
					else
					{
						String log="第"+(i+1)+"行插入失败："+msg;
						logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);										
					}
//					String log="第"+(i+1)+"行出错：";
//					log+=e.getMessage();
//					try {
//						logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);
//					} catch (ServiceException e1) {
//						// TODO Auto-generated catch block
//						e1.printStackTrace();
//					}					
					continue;
				}
//				if (i % 10000 == 0) {
//					autoService.executeSqlmore(lists);
//					lists.clear();
//				}
//				if (i % 1000 == 0) {
//					autoService.executeSqlmore(lists);
//					lists.clear();
//				}
//				else {
//					lists.add(strSql);
//				}
			}
		}		
 		int datarownum=rowSize-1-emptyrownum;
 		if(datarownum==0)
 		{
 			String msg="没有数据！";
 			return msg;	
 		}
 		if(successrownum<(rowSize-1-emptyrownum))
 		{
 			int failrownum=rowSize-1-emptyrownum-successrownum;
 			String msg=successrownum+"行导入成功，"+failrownum+"行导入失败。失败原因请查看日志！";
 			return msg;	
 		}		
 		//return 0;
 		return "success";
//		if (lists.size() != 0) {
//			autoService.executeSqlmore(lists);
//			lists.clear();
//		}
	}
	
	public String importPipesection(ExcelTool et)throws IOException {
		String res="";
		String sql = "";
		int rows = et.GetRowCount();
		int cols = et.GetColumnCount();
		String fieldType="";
		for(int i=2;i<=rows;i++)
		{
			boolean isError=false;
			sql = "insert into PTEM_PIPESECTION(ID,PIPESECTIONNO,RUNPRESSURELEVEL," +
			"BEGINNODEY,BEGINNODEX,BEGINNODEH,BEGINNODECODE,BEGINNODENAME,ENDNODEY," +
			"ENDNODEX,ENDNODEH,ENDNODECODE,ENDNODENAME,BEGINNODEL,BEGINNODEB," +
			"BEGINNODEELLIPSOIDH,ENDNODEL,ENDNODEB,ENDNODEELLIPSOIDH,PIPELINENO," +
			"PRESSURELEVEL,AERATEDATE,PAVEMODE,MATERIAL,MATERIALMARK,DIAMETER," +
			"OUTERDIAMETER,THICKNESS,PLANELENGTH,REALLENGTH,MANAGEUNIT,MANAGEDEPARTMENT," +
			"JUDGEREPEAT,REMARK,SIGNEDUNIT,SIGNED)" +
			"values(SEQ_PTEM_PIPESECTION.nextval";
			cols=35;
			for(int j=1;j<=cols;j++)
			{
				String strValue="";								
				strValue =et.GetCellText(i, j);	
				// 单元格中内容为空、“不详”或“/”
				if (strValue.equals("null")||strValue==null||
					 strValue.equals("")||strValue.equals("/")) 
				{
					
					sql += ",''";
					
					continue;
				}
				if(j>=13&&j<=18)//起点经度L-椭球高度H
				{
					strValue = strValue.replace("E", "").replace("N", "").replace("W",
					"").replace("S", "");
					sql+=","+strValue;
				}
				else if(j==21)	//通气时间
				{
					String strValeDate=changeDateValue(strValue);	
					if(strValeDate.indexOf("日期转换失败")!=-1)
					{
						isError=true;
						break;
					}
				}
				else
				{
					sql+=",'"+strValue+"'";
				}
			}
			sql+=")";
			if(isError==false)
			{
				autoService.executeSql(sql);
			}
			
		}
		res="success";
		return res;
	}
	public String importData(String tablename,ExcelTool et) throws IOException {
		String res="";
		if(tablename.equals("PTEM_PIPESECTION"))
		{
			res=importPipesection(et);
		}
		return res;
	}
	public void importData() throws IOException {	
		getRequest().setCharacterEncoding("UTF-8");//传值编码
		getResponse().setContentType("text/html;charset=UTF-8");//设置传输编码
		// 获取文件路径
		String filepath = filePath.getAbsolutePath();
		PrintWriter out = getResponse().getWriter();
		// 实例化一个工作簿对象
		try {
			ExcelTool et = new ExcelTool(filepath);
			// 获取该工作表中的第一个工作表
			// 获取该工作表的行数，以供下面循环使用
			int rowSize = et.GetRowCount();
			int cols = et.GetColumnCount();
			if (rowSize < 2) {
				out.print("{\"result\":\"没有数据！\"}");
				out.flush();
				out.close();
				return;
			}
			
			String res=importData("PTEM_PIPESECTION",et);						
			if(res.equals("success")){
				out.print("{\"result\":\"success\"}");
			}
			else
			{				
				String msg="{\"result\":\""+res+"\"}";
				out.print(msg);
			}	
			et.Save();
			out.flush();
			out.close();
		} catch (Exception ex) {
			ex.printStackTrace();
			out.print("{\"result\":\"error\"}");
			out.flush();
			out.close();
		}
	}
	public void importPersonData() throws IOException {		
		getRequest().setCharacterEncoding("UTF-8");//传值编码
		getResponse().setContentType("text/html;charset=UTF-8");//设置传输编码
		// 获取文件路径
		String filepath = filePath.getAbsolutePath();
		// 获取主表ID
		String formId = getRequest().getParameter("formId");
		String filenameExcel= getRequest().getParameter("filenameExcel"); //Excel文件路径
		String filenamePDF = getRequest().getParameter("filenamePDF"); //PDF压缩包名称
		String filenamePhoto = getRequest().getParameter("filenamePhoto");//照片压缩包名称	
		PrintWriter out = getResponse().getWriter();
		String beginDate = PubMethod.getAddtime();
		String desPDFDir="";//PDF目标目录
		String desPhotoDir=""; //照片目标目录
		// 获取主表名称
		String strSql = "select form_cn_name from auto_forms_new where id='"
				+ formId + "'";
		List tableList = autoService.getDatabySql(strSql);
		String formCnName = tableList.get(0).toString();
		//
		try {
			//获取上传路径
			String saveDirectory=getUploadAttachmentDir();
			//上传附件
			if((filenamePDF != null && !filenamePDF.equals(""))
				||(filenamePhoto != null && !filenamePhoto.equals(""))	
			  )
			{
				desPDFDir=getDesDir(filenamePDF,saveDirectory);
				desPhotoDir=getDesDir(filenamePhoto,saveDirectory);
				String res=uploadAttachment(filenamePDF,filenamePhoto,saveDirectory,
						desPDFDir,desPhotoDir);
				if(!res.equals("success"))
				{
					String msg="{\"result\":\""+res+"\"}";
					out.print(msg);				
					out.flush();
					out.close();
					String log=filenameExcel+res;
					logService.saveLogInfo(this.getLogBase(), formCnName,"导入文件",log,4);
					return;
				}
			}	
			
			// 实例化一个工作簿对象
			ExcelTool et = new ExcelTool(filepath);
			// 获取该工作表中的第一个工作表
			// 获取该工作表的行数，以供下面循环使用
			int rowSize = et.GetRowCount();
			int cols = et.GetColumnCount();
			if (rowSize < 2) {
				//out.print("{\"result\":\"error\"}");
				out.print("{\"result\":\"没有数据！\"}");
				out.flush();
				out.close();
				return;
			}
			
			// 获取子表ID
			String formIdChild = null;
			String sqlTemp = "select by_table_name_id from auto_forms_button t"
					+ " where t.this_table_name_id='" + formId + "'";
			List listTemp = autoService.getDatabySql(sqlTemp);
			String res="";
			if (listTemp.size() != 0)// 含子表
			{
				formIdChild = listTemp.get(0).toString();
				isHasChild = true;
				res=importPersonDataHasChild(formId, formIdChild, et, rowSize, cols,
						desPDFDir,desPhotoDir,formCnName);
			} 
			else // 不含子表
			{
				isHasChild = false;
				res=importPersonDataNoChild(formId, et, rowSize, cols,
						desPDFDir,desPhotoDir,formCnName);
			}
			et.Save();
			if(res.equals("success"))
			{
				System.out.println("完成:" + beginDate + "---"
						+ PubMethod.getAddtime());
				addMessage("导入成功！");
				out.print("{\"result\":\"success\"}");
			}
			else
			{
				System.out.println("完成:" + beginDate + "---"
						+ PubMethod.getAddtime());
				//String msg="{\"result\":\""+res+"\"}";
				//res="请查看日志";
				String msg="{\"result\":\""+res+"\"}";
				out.print(msg);
				//String log=filenameExcel+res;
				//logService.saveLogInfo(this.getLogBase(), tableName,"导入文件",log,4);									
			}	
			out.flush();
			out.close();
		} catch (Exception ex) {
			ex.printStackTrace();
			out.print("{\"result\":\"error\"}");
			out.flush();
			out.close();
		}
	}

	public void importGuanduan() throws IOException {	
		getRequest().setCharacterEncoding("UTF-8");//传值编码
		getResponse().setContentType("text/html;charset=UTF-8");//设置传输编码
		PrintWriter out = getResponse().getWriter();
//		getRequest().setCharacterEncoding("UTF-8");//传值编码
//		getResponse().setContentType("text/html;charset=UTF-8");//设置传输编码
//		
		// 获取文件路径
		String filepath = filePath.getAbsolutePath();
		try {
			//获取上传路径
			String saveDirectory=getUploadAttachmentDir();
			File file = new File(saveDirectory);
			if (!file.exists()){
				file.mkdirs();
			}
			String filename = PubMethod.GetTimerName();
			String savePath = saveDirectory+"\\"+filename+".xlsx";
			PubMethod.SaveSampleInputFile(filepath,savePath);
			
			InputStream is = new FileInputStream(savePath);
			XSSFWorkbook  hssfWorkbook = new XSSFWorkbook(is);
			XSSFSheet  hssfSheet = hssfWorkbook.getSheetAt(0);
			LogInfo loginfo=this.getLogBase();
			String res=autoService.importGuanduan(hssfSheet,loginfo);
			if(!res.equals("success"))
			{
				//logService.saveLogInfo(this.getLogBase(), "表C 管段","导入文件",res,4);
				//String msg="{\"result\":\""+"导入失败"+"\"}";
				String msg="{\"result\":\""+res+"\"}";
				out.print(msg);
				return;
			}
			// 实例化一个工作簿对象
			//ExcelTool et = new ExcelTool(savePath);
			//et.Save();
			out.print("{\"result\":\"success\"}");

		} catch (Exception ex) {
			ex.printStackTrace();
			out.print("{\"result\":\"error\"}");
		}
	}

	/**
	 * 设备导出 void
	 * 
	 * @date Apr 21, 2015 2:18:05 PM
	 */
	public void exportExcelLog() {
		try {
			//String formId = getRequest().getParameter("formId");
			String ids = getRequest().getParameter("ids");
			
			Calendar cal = Calendar.getInstance();
			//SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
			//String fileName = formatter.format(cal.getTime()) + ".xlsx";
			String fileName ="日志"  + ".xlsx";
			String pathUrl = getRequest().getSession().getServletContext()
					.getRealPath("");
			String sourcefilepath = pathUrl + "\\excelfile\\temp.xlsx";
			String targetfilepath = pathUrl + "\\excelfile\\linshi\\"
					+ fileName;
			File targetfile = new File(targetfilepath);
			if (targetfile.exists()) {
				targetfile.deleteOnExit();
			}
			copyFile(new File(sourcefilepath), new File(targetfilepath));
			ExcelTool et = new ExcelTool(targetfilepath);
			List<String> filecnnameList=new ArrayList();
			filecnnameList.add("组织名称");
			filecnnameList.add("用户名称");
			filecnnameList.add("功能菜单名称");
			filecnnameList.add("操作模块名称");
			filecnnameList.add("日志事件");
			filecnnameList.add("IP地址");
			filecnnameList.add("日志时间");
			for (int j = 0; j < filecnnameList.size(); j++) {
				String title=filecnnameList.get(j);
				et.SetCells(1, j + 1, title);		
			}
		
			String strSql = "select LOG_ORG_NAME,LOG_USER_NAME,LOG_MODULE_NAME," +
					"LOG_TYPE,LOG_LOGIN_EVENT,LOG_LOGIN_IP,LOG_CREATTIME from SYS_LOG ";
			strSql += " where LOG_ID in(" + ids + ")";
			try{
				List lists = autoService.getDatabySql(strSql);
				for (int i = 0; i < lists.size(); i++) {
					int rowIndex = 2 + i;
					Object[] objs = (Object[]) lists.get(i);
					for (int j = 0; j < filecnnameList.size(); j++) {
						String strval="";
						if(objs[j]!= null)
						{
							strval=objs[j].toString();
						}
						et.SetCells(rowIndex, j + 1, strval);
					}
				}
				et.Save();
				exportFile(targetfilepath);
			}catch (Exception e)
			{
				et.Save();
			}			
		} catch (Exception e) {
			
			e.printStackTrace();
		}
	}
	public void exportExcel() {
		try {
			String formId = getRequest().getParameter("formId");
			String ids = getRequest().getParameter("ids");
			String strSql = "select form_en_name,form_cn_name from auto_forms_new where id='"
					+ formId + "'";
			List tableList = autoService.getDatabySql(strSql);
			Object[] tableobjs=(Object[])tableList.get(0);
			String tableName = tableobjs[0].toString();
			String tablenamecn= tableobjs[1].toString();
			Calendar cal = Calendar.getInstance();
			//SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
			//String fileName = formatter.format(cal.getTime()) + ".xlsx";
			String fileName =tablenamecn  + ".xlsx";
			String pathUrl = getRequest().getSession().getServletContext()
					.getRealPath("");
			String sourcefilepath = pathUrl + "\\excelfile\\temp.xlsx";
			String targetfilepath = pathUrl + "\\excelfile\\linshi\\"
					+ fileName;
			File targetfile = new File(targetfilepath);
			if (targetfile.exists()) {
				targetfile.deleteOnExit();
			}
			copyFile(new File(sourcefilepath), new File(targetfilepath));
			ExcelTool et = new ExcelTool(targetfilepath);
			
			// strSql = "select t.cn_name,t.field_name from auto_forms_field t
			// where t.Field_Name<>'ID' " +
			// "order by t.show_seq";
			strSql = "select t.cn_name,t.field_name,t.field_type from auto_forms_field t where t.Field_Name<>'ID' "
					+ "and t.forms_id=" + formId + " order by t.show_seq";

			List filecnnameList = autoService.getDatabySql(strSql);
			String fieldnames = "";
			for (int j = 0; j < filecnnameList.size(); j++) {
				Object[] objs = (Object[]) filecnnameList.get(j);
				et
						.SetCells(1, j + 1, objs[0] == null ? "" : objs[0]
								.toString());
				fieldnames += objs[1].toString() + ",";
			}
			if (fieldnames.length() > 0) {
				fieldnames = fieldnames.substring(0, fieldnames.length() - 1);
			}
			strSql = "select " + fieldnames + " from " + tableName + " ";
			strSql += " where id in(" + ids + ")";
			List lists = autoService.getDatabySql(strSql);
			for (int i = 0; i < lists.size(); i++) {
				int rowIndex = 2 + i;
				Object[] objs = (Object[]) lists.get(i);
				for (int j = 0; j < filecnnameList.size(); j++) {
					String strval="";
					if(objs[j]!= null)
					{
						strval=objs[j].toString();
					}
					Object[] fieldnameobjs = (Object[]) filecnnameList.get(j);
					String fieldname=fieldnameobjs[0].toString();
					String fieldtype=fieldnameobjs[2].toString();
//					if(fieldname.equals("管线编号"))
//					{
//						strval="\r"+strval;
//					}
					if(fieldtype.equals("VARCHAR2"))
					{
						strval="\r"+strval;
					}
					et.SetCells(rowIndex, j + 1, strval);
//					et.SetCells(rowIndex, j + 1, objs[j] == null ? "" : objs[j]
//							.toString());
//					et.SetCellsText(rowIndex, j + 1, objs[j] == null ? "" : objs[j]
//					                             							.toString());
				}
			}
			et.Save();
			exportFile(targetfilepath);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void exportFile(String filepath) {
		File file = new File(filepath);// 构造要下载的文件
		if (file.exists()) {
			InputStream ins;
			try {
				ins = new FileInputStream(filepath);
				// 构造一个读取文件的IO流对象
				BufferedInputStream bins = new BufferedInputStream(ins);// 放到缓冲流里面
				OutputStream outs = getResponse().getOutputStream();// 获取文件输出IO流
				BufferedOutputStream bouts = new BufferedOutputStream(outs);
				getResponse().setContentType("application/x-download");// 设置response内容的类型
				getResponse().setHeader(
						"Content-disposition",
						"attachment;filename="
								+ URLEncoder.encode(filepath, "UTF-8"));// 设置头部信息
				int bytesRead = 0;
				byte[] buffer = new byte[8192];
				// 开始向网络传输文件流
				while ((bytesRead = bins.read(buffer, 0, 8192)) != -1) {
					bouts.write(buffer, 0, bytesRead);
				}
				bouts.flush();// 这里一定要调用flush()方法
				ins.close();
				bins.close();
				outs.close();
				bouts.close();
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			System.out.println("下载的文件不存在");
		}
	}

	/**
	 * 获取设备台账信息 void
	 * 
	 * @author Zhanxm
	 * @date Jul 31, 2015 3:14:18 PM
	 */
	public void queryEquipment() {
		try {
			String yiqimc = StringUtil.encodingUrl(getRequest().getParameter(
					"yiqimc"));
			String guigexh = StringUtil.encodingUrl(getRequest().getParameter(
					"guigexh"));
			String type = StringUtil.encodingUrl(getRequest().getParameter(
					"type"));

			Map<String, String> filterMap = getPagerMap();
			if (null != yiqimc && !"".equals(yiqimc)) {
				yiqimc = StringUtil.encodingUrl(yiqimc);
				filterMap.put("yiqimc", yiqimc);
			}
			if (null != guigexh && !"".equals(guigexh)) {
				guigexh = StringUtil.encodingUrl(guigexh);
				filterMap.put("guigexh", guigexh);
			}
			if (null != type && !"".equals(type)) {
				filterMap.put("type", type);
			}
			PageResult result = epService.queryEquipmentTz(filterMap);
			String[] viewArray = { "ID", "yiqimc", "guigexh", "zhizaocs",
					"zhizaobh" };
			String str = getColumnJson(result, viewArray);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// ---------------------------仪器管理部分---------------

	/**
	 * 查看仪器是否维修或者送检
	 */
	public void CheckIsUsing() {

	}

	/**
	 * 拷贝文件
	 * 
	 * @param sourceFile
	 * @param targetFile
	 * @throws IOException
	 */
	public static void copyFile(File sourceFile, File targetFile)
			throws IOException {
		BufferedInputStream inBuff = null;
		BufferedOutputStream outBuff = null;
		try {
			// 新建文件输入流并对它进行缓冲
			inBuff = new BufferedInputStream(new FileInputStream(sourceFile));

			// 新建文件输出流并对它进行缓冲
			outBuff = new BufferedOutputStream(new FileOutputStream(targetFile));

			// 缓冲数组
			byte[] b = new byte[1024 * 5];
			int len;
			while ((len = inBuff.read(b)) != -1) {
				outBuff.write(b, 0, len);
			}
			// 刷新此缓冲的输出流
			outBuff.flush();
		} finally {
			// 关闭流
			if (inBuff != null)
				inBuff.close();
			if (outBuff != null)
				outBuff.close();
		}
	}

	public Long getOrgIdByName(String orgName) {
		Long orgId = 1l;
		String sql = "select org_id from sys_organization where org_name='"
				+ orgName + "'";
		List listbumenid = autoService.getDatabySql(sql);
		if (listbumenid.size() > 0) {
			orgId = Long.parseLong(listbumenid.get(0).toString());
		}
		return orgId;
	}

	public EquipmentService getEpService() {
		return epService;
	}

	public void setEpService(EquipmentService epService) {
		this.epService = epService;
	}

	public TdmEquipment getTequipment() {
		return equipment;
	}

	public void setTequipment(TdmEquipment tequipment) {
		this.equipment = tequipment;
	}

	public Long getEid() {
		return eid;
	}

	public void setEid(Long eid) {
		this.eid = eid;
	}

	public IAutoService getAutoService() {
		return autoService;
	}

	public void setAutoService(IAutoService autoService) {
		this.autoService = autoService;
	}

	public File getFilePath() {
		return filePath;
	}

	public void setFilePath(File filePath) {
		this.filePath = filePath;
	}

	public List getUploadfile() {
		return uploadfile;
	}

	public void setUploadfile(List uploadfile) {
		this.uploadfile = uploadfile;
	}

	public List getUploadfileFileName() {
		return uploadfileFileName;
	}

	public void setUploadfileFileName(List uploadfileFileName) {
		this.uploadfileFileName = uploadfileFileName;
	}

	public TdmEquipment getEquipment() {
		return equipment;
	}

	public void setEquipment(TdmEquipment equipment) {
		this.equipment = equipment;
	}

}
